.net - How to set ID in Object Oriented Code -


When I'm talking about object-oriented programming for a 3-level application, I'm a little confused. Here's a small example of what I'm trying to do (I will shorten the database design to simplify it) Let's say I'm making a ticket help desk system, a ticket description, a responsible person, a The due date and definitely an ID (unique).

Assume that ID is only an identity column, which is an integer type and its value (SQL Server). It gets its value only once it is included.

Now just a few sample pseudo codes (this can not be correct, so do not give out syntax bugs, just try to find an answer about how to store the ID).

I can easily create a ticket class

  public class ticket {private string m_description; Private date m_duedate; Private string m_responsible; Private Industries M_ID; // should it be read only ??? Or ... how to // so i can get a bunch of properties / set these private variables public property responsible ({return m_responsible;} set {m_responsible = value;}} // and so on .. No, do not worry about the syntax. Now I should have a get / set for the ID?}  

Okay so I called this class a ticket..what would happen When I make a ticket object and come to put it in my BLL (Business Logic Layer) Shakespeed

  Blal B = New Blal (); Ticket T = New Ticket (); T.Respensible = Some String; T.DueDate = someDate; T.Description = someLongString; // Use BLL to create a ticket object and pass it to DAL? // then specify ID in TID from database ??? T.ID = bll.InstertTicket (T);  

// It passes to BLL, which talks about it and sends it to DAL, makes an INSERT statement and then returns the ID number given by the database Purchaser is. / P>

So my question is, should be given me to the tee. ID is required to be mentioned when or after the insert. I am always confused with OOP because I think it makes the norms more complicated and just crossing a whole number of parameters.

Okay, after somebody, I can help to understand whether I need to get / set on ID and whether I should return that value to my interface. My second question is about updates? Assume that an end user gets a ticket, so on my interface I leave behind some ticket data and any update wants to update and tells the due date. When I "submit" these changes, would I just want to create a ticket object, set all available / set property value and what is it? Or should I just pass ID number and all the parameters in my BLL and should handle it all?

Hope this all makes sense!

Thanks a lot guys!

The answer is whether it depends on the framework or library you are using.

All BLLs call you all to just ticket T = new ticket () , you use t = b.CreateTicket () or something May be needed. ID can be a floating value or just null / 0 until it persists.

On the other side of your question:

If you want to update a ticket, definitely do not do create a new ticket object. You can update the object.

Perhaps you should clarify the question in light of a particular library or technique.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -