reset password
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: Page and Revision.

Please discuss the pros and cons of the following design decisions:

1. (10pt) Bidirectional association vs. unidirectional association between Page and Revision.

2. (10pt) Implementing the Subscribable interface vs. keeping Set<User> subscribers in Page.

3. (10pt) Keeping file attachments (i.e. Set<File> attachments) in Page vs. keeping them in Revision.

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.

If I want to traverse between wikiPage and wikiRevision of their corresponding property then it will be easy.

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 Page and Revision.

    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 Subscribable interface vs. keeping Set<User> subscribers in Page.

   Pros:

   Implementing the Subscribable interface, as an "is-a" relationship, inherit all the methods of subscribable.  While  keeping  Set<User> doesn't have the interface methods for clients to call.  It also simplifly the mapping files making by using subclass mapping.   

    keeping Set<User> subscribers  has simpler database design. 

    Cons:

     The reverse of about statements.

3. (10pt) Keeping file attachments (i.e. Set<File> attachments) in Page vs. keeping them in Revision.

     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. Set<File> attachments) in revision is a better option because when we revert pages to particular revision we able to provide correct attachment information about the revision.

For example: if revision 1 have one attachment (A) and revision 2 have 2 attachments (A and B) and when we revert page to revision 1 then we will able to display correct attachment of revision 1(i.e. A).

If we keep file attachment in page then we will lose the revision information for attachments.

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.

File attachments should be in Revision class. If user1 edits the page with a file attachment which will be revision 1. Later user2 makes changes to same wiki page with a file attachment creating revision2. Now if we want to revert back revision1 we do not need file attachment 2. So to keep track which user has attached the file and in which revision we should implement file attachment in Revision class.

praticsula
Posts: 5
Posted 19:35 May 03, 2010 |

3) Implementing the Subscribable interface vs. keeping Set<User>  subscribers in Page.

Pros: By Implementing the interface, the user object and the subscribable object can be passed to the subsription table ,
since the subscription table has the users, we can get the users from it and user object would give us user's details like email id

Cons:Design becomes complicated

Pros : keeping Set<User> subscribers in Page, we can query all users who subscribed for a particular wiki page and viseversa. This keeps the design simple

Pallavi0205
Posts: 30
Posted 19:40 May 03, 2010 |

2. By using Set<user> we will get all properties of the user which is not required. We only required a few properties of user but by implementing Subscribable interface we get all the properties of interface which is minimum. which is good for performance.

Example: For example we get subscriber id by implementing Subscribable interface and we get other information like email from User whenever required.

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.
 Bidirectional association between the Page(one to many) and Revision(many to one) is complex and involves the use of joins. Unidirectional association makes simpler designa nad mapping.
 
2.Implementing the Subscribable interface vs. keeping Set<User>  subscribers in Page.
Implementing the Subscribable interface, we need to implement all the abstract methods of interface. and using the Set<User> subscribers in page we can get the required properties like name and email of the user.

3.Keeping file attachments (i.e. Set<File> attachments) in Page vs. keeping them in Revision.

Each file attachment is considered a new one. hence it is easy to map attachment with a revision rather than a page.
 

prajaktas
Posts: 10
Posted 19:50 May 03, 2010 |

1. Bidirectional association vs. unidirectional association between Page and Revision.

Bidirectional is better. If we have unidirectional, we insert a new revision then the revision table will be updated with the revision no and wiki page no. but the wiki table will not be updated with the revision no. we will have to write one more insert query to update wiki table. If we have bidirectional one insert query will update both the tables.

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. Set<File> attachments) in Page vs. keeping them in Revision.

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. Set<File> attachments) in Page vs. keeping them in Revision.

Keeping file attachments (i.e. Set<File> attachments) in Page- this will have the attachements at the page level, which is not the requirement

keeping them in Revision.- Adding attachment is also a kind of change done to the revision which will be treated as a new revision , so file attachments should be in Revision .Retrieving a particular attachment of a particular revision from revision page will be easier to mantain

praticsula
Posts: 5
Posted 20:28 May 03, 2010 |

Unidirection between the page and revision

Pros : Page can have more than one revision. By using the page object we can get the list of revision.

Cons : If we need to reach the page object from revision object it not possible with unidirectional

Bidirectional between page and revision

Pros: By using bidrectional we can access the page object using revison object and revision object with page object.

Cons : Page(one to many) and Revision(many to one) is complex and involves the use of joins. The entire object realtion dump into the in memory.

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(?)
update revisions set page_id=? where revision_id=?

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. Set<File> attachments) in Page vs. keeping them in Revision.

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
revision therefor each time speacilly in the wiki page all the users are adding the new and important information to the wiki page and rearly someone is going to revert to its original (First) revision so unidiectional association is perfect rather than bidirectional which increase the overhead to the application.


b) Its better to implementing the Subscribable interface for the subscribers in Page because we can use all the properties of the interface
which improve the performance of the application and if you want to reuse the code for some other application as well.

c) When you keeps file attachments in Revision its easy when you revert the page to its earlier revision version which includes the path of
file attached.
Its overhead when you keep it at the Page level, then we have to keep track of the all file attachment at the Page which increase the
overhead to the application.

alomo
Posts: 70
Posted 22:19 May 03, 2010 |

1.
Bidirectional association
Pros: easy access to revisions from page and vice versa.
Cons: increase of redundancy
Unidirectional association
Pros: easier to implement; reducing redundancy.
Cons: complex queries for retrieving Page information from its Revision.

2.
Implementing the Subscribable interface
Pros: Implementing the Subscribable interface is preferable from the point of using same way of subscribing to different services provided by the project.
Cons: Retrieving subscribers for particular page would be more complicated
Keeping Set<User> subscribers in Page
Pros: more "object-oriented" approach
Cons: increases redundancy.

3.
Keeping attachments in Page
Pros: Simpler files hierarchy. When the user sets the password on some page, this security would be inherited by all page attachments.
Cons: attached files may have own version (like the libraries in the Eclipse project could be version controlled)
Keeping attachments in Revision
Pros: possibility to track not (missed in original post) only changes in content of the page, but the versions of attachments as well.
Cons: security control for attachments became more complicated.

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
pros: It's easy to get data by simple query from page, and also from revision.
cons: It Increases maintenance cost. We have to make sure all bidiretional associated objects are created or deleted correctly.

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 |
cysun wrote:

A wiki page may have a number of revisions, so we'll model it with two classes: Page and Revision.

Please discuss the pros and cons of the following design decisions:

1. (10pt) Bidirectional association vs. unidirectional association between Page and Revision.

2. (10pt) Implementing the Subscribable interface vs. keeping Set<User> subscribers in Page.

3. (10pt) Keeping file attachments (i.e. Set<File> attachments) in Page vs. keeping them in Revision.

Whoever gives the best answer to a question receives the credit for that question, which will be added to their HW3 grade.

 

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 "Subscribable interface" is useful in "forum" , survey and our wiki. We just implement our interface for subscribe or unsubscribe. .

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
for both side between Page and Revision. Database has all information you need.
Unidirectional association is not efficient sometimes by keeping all in your application memory.
You need to write a query to get some information.


2.Keeping Set<User> subscriber in Page is easy to access by getting all properties.
Nevertheless, Implementing the Subscribable is recommended.
It is more efficient in order to save the object in a binary form using the input output stream.
It doesn't have to go back to database to retrieve all properties. you can just inherit properties required.

 

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.
Set<File> would be very large. Also, Page would have a different version of file attachment by each revision.
In that case, Page should hold all different version of file attachment.

Last edited by hibbol at 12:48 May 04, 2010.
prenteria
Posts: 13
Posted 22:49 May 04, 2010 |
1. (10pt) Bidirectional association vs. unidirectional association between Page and Revision.

 Bidirectional association:
PRO
- It would have direct relationship when searching for revisions having a page. As well as it
 would have direct association also when looking for a page having its revision number.
- Simple queries to display information because is mapped on both associations.
CON
- Hard to maintain tables and relationships
- Demanding more computer resources in case of large sets of information

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:

  • The question asks for pros and cons, not which one is better or preferable, so you need to discuss both sides.
  • Understanding something doesn't mean you can explain it clearly and correctly.
  • There seems to be lots of misconception about object and object reference. We need discuss this in class.
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.