Author | Message |
---|---|
cysun
Posts: 2935
|
Posted 17:36 May 03, 2010 |
A wiki page may have a number of revisions, so we'll model it with two classes: Please discuss the pros and cons of the following design decisions:
1. (10pt) Bidirectional association vs. unidirectional association between
2. (10pt) Implementing the
3. (10pt) Keeping file attachments (i.e. Whoever gives the best answer to a question receives the credit for that question, which will be added to their HW3 grade. |
hareshdhola
Posts: 6
|
Posted 17:50 May 03, 2010 |
1. I will bidirectional because it make object access easy as I can traverse both the directions. Ex. I have wikiPage and wikiRevision. There is one property of wikiPage, lastRevision which is object of wikiRevison. Now, I have one property in wikiRevision, which has object of wikiPage. |
hareshdhola
Posts: 6
|
Posted 17:54 May 03, 2010 |
2. I have used Set<User> for subscribers because I want to make it simple and less confusing. 3. I would go with wikiRevision because each Revision can have different attached files. Like in initial revision user may not have any attachment but later he/her can add it. So, each revision should have its attachment files. |
jason1353
Posts: 12
|
Posted 18:03 May 03, 2010 |
1) I see Page as mother and revisions as childeren, but with this unique property that each child could become mother, the relationship is better to be unidirectional beause all we need is to traverse a Set of Revisions and find the one we like and then copy its contents to the main Page, and the save it as a new revision, we rarely need to reach to the main page from a revision (in case we want to implement Biderectional association.
2)I personally prefer the second option because it gives me a bidirectional access between page and user Sets. We can easily find which user is subscribed for which page and which page is subscribed by which user.
3) I prefer keeping that Set in Page because revisions keep only referrences to those attachments like <img href="somefile" /> but the main attachment file is kept in the main Page, this way we save memory, (every attachment object is kept in one place) and by reverting to a previos revision, nothing is changed in that revision and in the main page. |
ashwini
Posts: 7
|
Posted 18:59 May 03, 2010 |
1. Bidirectional association would be better choice if there is a large number of pages with each page having minimal number of revisions. Bidirectional association makes the object access from the other class easier/faster. But this also means there is an overhead to keep objects in both the classes (hence minimal number of revisions - which is usually the case). 3. Keeping file attachments in Revision is easier of the design choices as different versions of the same file does not have to be maintained. Different revisions may have different file attachments (or different versions of the same file). Keeping file attachments in Revision lets us achieve this. There is an overhead of keeping unchanged attachments between versions. Last edited by ashwini at
19:19 May 03, 2010.
|
p0941
Posts: 95
|
Posted 19:06 May 03, 2010 |
1. (10pt) Bidirectional association vs. unidirectional association between Pros: Bidirectional association: Easier to find Page from Revision and Revision from Page, in query language. Unidirectional association : Simpler model design and mapping file making. Cons: The reverse of about statements.
2. (10pt) Implementing the Pros:
Implementing the
keeping Cons: The reverse of about statements.
3. (10pt) Keeping file attachments (i.e. Pros: Keeping file attachments in Revision makes each revision able to have its own attachment. Keeping file attachments in Page makes attachments shared by each revision Cons: The reverse of about statements.
|
Pallavi0205
Posts: 30
|
Posted 19:11 May 03, 2010 |
3. Keeping file attachments (i.e.
|
prajaktas
Posts: 10
|
Posted 19:17 May 03, 2010 |
3. Keeping file attachments (i.e. Set<File> attachments) in Page vs. keeping them in Revision. |
praticsula
Posts: 5
|
Posted 19:35 May 03, 2010 |
3) Implementing the Subscribable interface vs. keeping Set<User> subscribers in Page. |
Pallavi0205
Posts: 30
|
Posted 19:40 May 03, 2010 |
Last edited by Pallavi0205 at
19:42 May 03, 2010.
|
hsankav
Posts: 18
|
Posted 19:42 May 03, 2010 |
Bidirectional association vs. unidirectional association between Page and Revision. |
prajaktas
Posts: 10
|
Posted 19:50 May 03, 2010 |
1. Bidirectional association vs. unidirectional association between Page and Revision. |
ashwini
Posts: 7
|
Posted 19:50 May 03, 2010 |
2. Implementing the Subscribable interface ensures that the methods for implementing subscription of Page/Topic/Mailinglist are the same (we can reuse the code). This makes it easier to maintain and add new features (eg: Daily digest or Weekly digest modes of subscription). Database mappings has to be done carefully. |
sunitha
Posts: 12
|
Posted 19:59 May 03, 2010 |
1. Bi-directional association between Page and Revision vs Uni-directional association between Page and Revision. a. Bi-directional association between Page and Revision Pros: Search on the Revisions entity is easy and will result in fetching the page by hibernate automatically.
b. Uni-directional association between Page and Revision. Pros: Unidirectional makes Revisions Entity to be reused by some other entity which needs Revision Entity. Cons: In case of search on Revision entity specific attributes, we always need to join Page and Revision.
2. Implementing Subscribable Interface vs keeping Set<User> in page. a. Implementing Subscribable Interface: Pros: Subscriptions can be extended beyond users such as Groups and search engines. Cons: Implemention will be complex, incase of supporting subscriptions beyond users like Groups and search engine. b.Keeping Set <User> in Page Pros: It is very easy to implement since addition of subscribers(Users) to a Page is just by calling add method on Set<User> Collection. Cons: Subscriptions beyond users like Groups is not possible.
3. Keeping file attachments (i.e. a. Keeping file attachments in Page level. Pros: Files that are non specific to revisions will be easier to manage and saves memory. Cons: Revision specific attachments is too complex since the database has to maintain all the attachments in each revision. b. Attachments at Revision level. Pros: If the user wants to revert to the specific revision, then the user can also retrieve the attachments that are specific to that revision. Cons: Files that are non specific to revisions are duplicated and hence increases memory. |
praticsula
Posts: 5
|
Posted 20:23 May 03, 2010 |
Keeping file attachments (i.e.
Keeping file attachments (i.e.
keeping them in |
praticsula
Posts: 5
|
Posted 20:28 May 03, 2010 |
Unidirection between the page and revision |
sunaina
Posts: 14
|
Posted 21:14 May 03, 2010 |
1. Bidirectional vs. Unidirectional association between Page and Revision: Unidirectional Association: Less complex but more tedious to maintain the relationships while editing. In the current example we may never want to go backwards i.e. from revision to the main page hence works better. Eg. the Page class{page_id(pk), title,..} and Revision class {revision_id(pk), page_id(fk), revision}. Lets say we have unidirectional mapping as Set<Revision> revisions in Page class. If we try to insert a new revision into the database. the sql queries will be something like:
insert into revisions(revision) values(?) Bidirectional: Bidirectional association makes changes made at one end visible to both the ends/parties which makes it easier to maintain database and write queries but not the best choice to our needs for this scenario. Eg.: we use Set <Revision> revisions in Page class and many-to-one mapping with Page in Revision. If we try same insert again, then: insert into revisions(revision,page_id) values(?, ?). Only one sql statement manages to insert the statement and maintain the relationship. 2. Implementing Subscribable interface provides more flexibility to change(more methods) the subscription policy for the page in future to owner and subscription options to users. While keeping set<users> as subscriber in page allows more flexible access and maintenance.
3. Keeping file attachments (i.e. Attachment sems to be associated with each revision hence must be maintained with the Revision. Different revisions of the same page could have different attachments. However if we have attachment as a property of page then several revisions could share the same file as attachment and have their own individually if required. |
mithawala
Posts: 8
|
Posted 21:55 May 03, 2010 |
a) Between Page and Revision unidirectional association will work perfectly beacause while creating a home page also you can create a first |
alomo
Posts: 70
|
Posted 22:19 May 03, 2010 |
1.
2.
3. Last edited by alomo at
15:28 May 05, 2010.
|
dfostersmith
Posts: 9
|
Posted 22:44 May 03, 2010 |
1: Unidirectional associations create acyclic graphs when mapping data objects and have less overhead. Although easier to manage it is not always feasible to capture real world scenarios Bidirectional associations can lead to cyclic graph in data object graphs and can also become a hindrance to Reflection. They are harder to manage than unidirectional associations and require more overhead.
2. By implementing the Subscribable interface we are not reinventing the wheel. This interface gives us all the features and methods that we might need for the application while offering the possibility of extending it. By using Set<Users> we still have to create the functionality of sending the updates to each page change.
3.Depending on the implementation of the project if the attachments are created for each revision that will become a waste of space to store copies of these attachments. This can be avoided if the implementation utilizes relative paths in the revisions for pointing to these file and these attachments were attached to a specific page. There is also the question of whether or not you want to be able to retrieve different revisions of the of a specific file. It might then be feasible to implement it in Revisions. |
rahulajit
Posts: 15
|
Posted 22:50 May 03, 2010 |
1. Bidirectional association between Page and Revision: Pros: Bidirectional association increases the interdependency between Page and Revision, i.e any changes made to the Page class will be reflected on the Revision class too. This model works good for our application as there are setter methods(like setting the author of a revision) in Revision class which may seem like independent functions of the Revision class but these changes have to be reflected on the respective Page object. It reduces the size of SQL queries and gives a better performance. Cons: It increases the size and complexity of our code. We have to be careful when the Page and Revision objects are created or removed. For instance, if you delete a Page object, it is likely that the Revision object still remains. For our wiki application, it would make no meaning to store Revisions when it doesn't have a reference to a Page object. Unidirectional association between Page and Revision: Pros: There's a looser coupling between the Page and Revision. Almost every function in the Revision class can be accessed through a Page object. It also makes sense to think that Revisions can not exist without a Page. Reduces the size and complexity of our code. Cons: If I insert a record into the Revision table I need to write a SQL query that takes care of both inserting data into the Revision table as well as making the reference to its corresponding Page table record as opposed to single SQL statement that can take care of both inserting data and maintaining relationship in bidirectional mapping. This clearly reduces the performance. 2. Implementing the Subscribable interface in Page: Pros: Subscribable interface is more generic as opposed to having it as a property in the Page class. This makes it more flexible for future changes or reuse of code in our application. It is possible that we could have a new requirement in the wiki application which requires us to provide subscription for it. In such instances the new class has to just implement Subscribable interface unlike having to create a new property in the new class to store the set of users. Secondly, we might need the data of all subscriptions used in CSNS, that is not just the subscriptions for a Page which is made easy with Subscribable interface. This also reduces the necessity of creating new tables for every type of subscription. Cons: We will have to override all the methods of the Subscribable interface in Page. Keeping Set<User> subscribers in Page: Pros: It is easier and faster when it comes to accessing the subscribers of a Page. Cons: It reduces the scope of reusability and changes we could make in our application. 3. Keeping Set<File> attachments in Page: Pros: It obviously reduces the complexity of mapping and retrieving the files associated to a Page. Cons: Revisions are created every time there is a change in the content of a Page. Some files could be associated to a particular content spoken in a newer revision of a Page. So if I were to revert back to an older revision then I should only have the files associated to that particular revision. It makes it difficult to associate files of a particular revision by keeping Set<File> attachments in Page even though it is possible as most likely the owner of a file could be the author of the revision associated. Keeping Set<File> attachments in Revision: Pros: Its easier to map the association between files and revision as files are rightly associated to a revision content over a page content. Cons: To retrieve files associated to a Page requires us to traverse through each and every revision associated to that Page. |
lma12
Posts: 13
|
Posted 02:54 May 04, 2010 |
1.
Bidirectional association
unidirectional association
pros: It's easy to maintenance. cons: We have to use complex queries to get data. 2.
Implementing the Subscribable interface
pros: Code reusable. it's easy to maintenance. cons: Inteface design is important. It's hard to find bugs if design is poorly.
Keeping Set<User> subscribers in Page
pros: It's easy to get subscribers data. cons: It Increases maintenance cost.
3.
Keeping file attachments in Page
pros: It's easy to get file attachments for a page. cons: It cannot track file attachements for specific revision.
keeping file attachments in Revision
pros: It can track file attachments for each revision. cons: complex queries. To get the attachments for a page, We have to access current revision first. |
CS320stu08
Posts: 22
|
Posted 02:56 May 04, 2010 |
1)Pros of Bidirectional Mapping: When we write the code its easier to reference back and fourth Pros of Unidirectional Mapping: Model design and mapping is user Cons of Unidirectional Mapping: To reference back and fourth is easier |
CS320stu08
Posts: 22
|
Posted 03:08 May 04, 2010 |
3) Keeping Set<File> attachments in Page Pros: I can't see any Cons: This doesn't help our need. The attachments are specific to Revision and the Page only consists the information of the latest revision. Due to this we cannot save attachments specific to different revisions in Page Keeping Set<File> attachments in Revision: Pros: The attachment are specific to revision. So, if we store the attachments in the revision and when we revert back to previous revisions the attachments to that specific revision can be easily retrieved as attachments are stored in terms of the revision it belongs. |
trivedidr
Posts: 54
|
Posted 11:19 May 04, 2010 |
ANS. : 1 It is easier to retrieve revision detail from page as well as from revision we'll find the page detail. as we have seen in class the example of account and customer and discuss about unidirectional and bidirectional design of data. In our case its easy to retrieve both class detail in bidirectional. ANS.:2
In our csns project " Like in table definition we put from which we get subscribe? eg.: if it is from wiki then we put "wiki", if it is from forum we put "forum" and so on.... so, using that interface we are designing such a database which have NO Redundancy and we can manage the subscriber of forum, survey and wiki in one table and same way unsubscribe it also. So, rather than having redundancy in database we have good design . So, I think it's good to use interface than set<user>.
ANS.: 3 I think it's better to have keep tracking of files in REVISION so, one can change it and and we can save it there. and finally we can retrieve it and display it easily. |
cs422@2009
Posts: 8
|
Posted 12:02 May 04, 2010 |
1) Bidirectional association vs. unidirectional association between Page and Revision Bidirectional association is a better choice. When we use bidirectional association between Page and Revision, the Page object can be accessed in Revision and Revision object can be accessed in Page easily. Unidirectional association provides simple design and can be used when we have to access large amounts of data. 2)Implementing the Subscribable interface vs. keeping Set<User> subscribers in Page. By implementing subscribable interface we can access the methods we want for e.g get the email Id of the user. By using Set<User> subscribers we get the users who subscribed that page. 3) Keeping file attachments (i.e. Set<File> attachments) in Page vs. keeping them in Revision. A file attachment should be stored in Revision because, an attachment is particular to a Revision, So when we store an attachment in Revision it is easy for us to access the attachments stored for a particular Revision. |
hibbol
Posts: 20
|
Posted 12:46 May 04, 2010 |
1.Bidirectional association is convinient to write a code to get reference Last edited by hibbol at
12:50 May 04, 2010.
|
hibbol
Posts: 20
|
Posted 12:46 May 04, 2010 |
3. Keeping file attachments in Page doesn't seem efficient in order to keep all files in your memory. Last edited by hibbol at
12:48 May 04, 2010.
|
prenteria
Posts: 13
|
Posted 22:49 May 04, 2010 |
Bidirectional association:
Unidirectional association:
PRO - We would have unidirectional association linking the page with all its revisions. CON - Long and complex queries to retrieve information from tables. 2. (10pt) Implementing the Subscribable interface vs. keeping Set<User> subscribers in Page.
Implementing the Subscribable interface:
PRO - We would use tested code that works for subscriptions. - We just need to adapt the interface to work with every wikipage editions. - Less code to type. CON - Subscribe interface desing not flexible. We need to implement specified routines.
Keepig Set<User> subscribers in Page:
PRO - We do not need to modify our design based on the logic and structure of the Subscribable interface. - We would customize the minimum routines needed to add this feature. CON - We need to design the needed arguments and functionality that would send the messages to the right receipients. 3. (10pt) Keeping file attachments (i.e. Set<File> attachments) in Page vs. keeping them in Revision.
Keeping file attachments in Page:
PRO - It would be one Set of Files per page. - The attaching and dropping file procedures would be independent of editing a page. CON - We would not know after what revision the files were attached. Keeping them in Revision: PRO - We would keep track of attachments per revision. If someone would revert the page to an earliest edition, it would bring also the available attachments at that time. CON - We would need to create a Set of files every time a revision is done. - Longer routines to access attached files per revision. |
cysun
Posts: 2935
|
Posted 14:06 May 05, 2010 |
This exercise is closed. |
cysun
Posts: 2935
|
Posted 14:17 May 05, 2010 |
And the winners are: 1. none 2. alomo, dfostersmith, rahulajit: +5 3. hareshdhola, Pallavi0205, prajaktas, sunitha, praticsula, sunaina, rahulajit, CS320stu08, cs422@2009, prenteria: +10 And some general comments:
|
JHautzinger
Posts: 14
|
Posted 14:59 May 05, 2010 |
Deleted Post. Looks like I took too long to submit it. Last edited by JHautzinger at
16:22 May 05, 2010.
|