SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2009
    Location
    A city equidistant from two coasts of India.
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How to design classes to handle Insert/Update and other roles effectively?

    I am not using MVC but I do wish to follow a nice pattern.

    My application is in C# 4.0, but the question here in relates to OOP concepts.
    My application is a small program which opens a data-entry screen. A Form is opened with several fields to be filled in by the user. This program stores information about pumps drilled in a city or a village. I want to design a Class to effectively manage this program and pump information in future.
    Each pump record comprises of following fields:

    (1) Pump drilling date
    (2) Place of drilling
    (3) Location
    (4) Latitude
    (5) Longitude
    (6) Sanction Number
    (7) Sanction Date
    (8) Name of Engineer
    (9) Drilling machine used
    (10) Depth & Diameter

    These are few primary fields from the long list of fields. I can create a simple class like:
    Code:
    Class Pump
    {
    	public Date DrillDate { get; set;}
    	public string Place {get;set;}
    	public string Location {get;set;}
    	......
    }
    -- I want a class to Insert or Update information in the database.
    -- I want a class to populate various DropDowns on the screen once the screen gets loaded.

    I can create an abstract class but looking at the ten fields mentioned above, I don't find any good reason to create an abstract class.

    Please help.

  2. #2
    SitePoint Evangelist praetor's Avatar
    Join Date
    Aug 2005
    Posts
    479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There is no need for abstract classses or things like that. Only a clear delimitation between application layers, i.e don't mix business logic with view logic or persistence logic. For database, use a micro orm like dapper.net or peta poco.
    The class to populate various dropdowns is called a view model, that is the model from where a view takes its data. The Pump class seems good enough for that. I think it's more of a basic architecture problem rathen than OOP.

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2009
    Location
    A city equidistant from two coasts of India.
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Both micro ORMs look good and easy. I am new to ORMs and so want to know whether there is a need to write stored procedures in the database or ORM handles parameterized queries?



    Quote Originally Posted by praetor View Post
    There is no need for abstract classses or things like that. Only a clear delimitation between application layers, i.e don't mix business logic with view logic or persistence logic. For database, use a micro orm like dapper.net or peta poco.
    The class to populate various dropdowns is called a view model, that is the model from where a view takes its data. The Pump class seems good enough for that. I think it's more of a basic architecture problem rathen than OOP.

  4. #4
    SitePoint Evangelist praetor's Avatar
    Join Date
    Aug 2005
    Posts
    479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No need for stored procedures

  5. #5
    SitePoint Enthusiast
    Join Date
    Oct 2009
    Location
    A city equidistant from two coasts of India.
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    Quote Originally Posted by praetor View Post
    No need for stored procedures
    I am referring to PetaPoco documentation. But I am not following where should the connection string go, in the Database.tt file or I need to derive a new class from the Database.tt template?

    Where should the INSERT/UPDATE/SELECT statements go? The Pump class is the base class.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •