Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to organize Java Business object classes
    primarykey
    data
    text
    <p>I am writing a web service and one of the operation in service is <code>getShortURL(String longURL)</code>. In this method I first check whether <code>longURL</code> exists in database, if yes, return it otherwise create a <code>shortURL</code>, insert it in database and return to client.</p> <p>My confusion is how to organize and name my classes. Apart from the web service class, right now I have 3 classes:</p> <ol> <li><code>URLData</code>: It just has URL attributes and getters and setters.</li> <li><code>MongoDB</code>: It connects to database(right now connection attributes are hard-coded in it), inserts in database, and retrieves raw string from database.</li> <li><code>MongoDBUtil</code>: This class has again <code>insert(URLData)</code> method, it calls <code>MongoDB.insert()</code> to insert into database. Also has <code>retrieveURLData</code> which in turn calls <code>MongoDB</code> equivalent method to do the actual job.</li> </ol> <p>Web service method sets <code>URLData</code> setters and calls <code>MongoDBUtil.retrieve</code> or <code>insert</code>.</p> <ol> <li>I am thinking that <code>URLData</code> class should be named <code>URLDataBusinessObject</code> and along with setters and getters it can have insert, update and delete methods.</li> <li><code>MongoDBUtil</code> can be renamed to UrlDAO and it can have different kinds of retrieve methods.</li> <li><code>MongoDB</code> is more kinda Select query class, not sure how to design and name it.</li> </ol> <p>Please advise</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload