Created
May 13, 2019 09:59
-
-
Save AnEnigmaticBug/ee2f0213f32a5e699142d239258efad2 to your computer and use it in GitHub Desktop.
This shows the various options I found for representing relations in OOP languages. This is for obtaining opinions from people on what style(s) is preferred.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/**Option-1**/ | |
data class Tag (val id: Long, val name: String, val icon: Int) | |
// subTasks contains tasks themselves. | |
data class Task(val id: Long, val name: String, val tags: List<Tag>, val subTasks: List<Task>) | |
/**Option-2**/ | |
data class Tag (val id: Long, val name: String, val icon: Int) | |
// subTasks contains ids of the tasks. | |
data class Task(val id: Long, val name: String, val tags: List<Tag>, val subTasks: List<Long>) | |
/**Option-3**/ | |
data class Tag (val id: Long, val name: String, val icon: Int) | |
// subTasks is not there in the class. | |
data class Task(val id: Long, val name: String, val tags: List<Tag>) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I see the following pros and cons in the following approaches:
Option-1
Pros
Cons
Option-2
Pros
Cons
Option-3
Pros
Cons
getSubTasksForTask(task)
Task
class itself tells us nothing about the existence of the concept of sub-tasks