Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Adding layers

Adding layers

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharpdatabaselinuxhelptutorial
23 Posts 6 Posters 6 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N N a v a n e e t h

    Naerling wrote:

    At this point, is anyone really disagreeing with me?

    Nope. Adding abstractions which make your code more easy are always good. But keep it in mind, more generalization will make lot of trouble and you will end up layering over and over to satisfy all the requirements. And these kind of abstractions won't help you on other projects as each project will have different requirements. So if you plan you generalize too much, you will end up writing another ORM tool like hibernate. An interesting read : Law of leaky abstractions[^] :)

    Best wishes, Navaneeth

    Sander RosselS Offline
    Sander RosselS Offline
    Sander Rossel
    wrote on last edited by
    #21

    Thanks for the article. I'll be sure to read it later! :)

    It's an OO world.

    1 Reply Last reply
    0
    • Sander RosselS Sander Rossel

      I've been programming with .NET for half a year now. It's all pretty great and fairly easy, but I can't help to think that some classes/components were made to have an extra shell around them. Take the whole process of connecting and reading/writing data from and to a database. At the very least we need a Connection object and a Command object and dependent on what you want to do you need a DataReader, DataAdapter, Parameters, CommandBuilders, etc... It seems to me that constantly creating all those objects, configuring them etc. seems like a lot of work. So it would seem to me that it is easier to create a class that requires some parameters in its constructor, has some methods and functions that manage all the just mentioned classes and simply gives a resultset using something like DBClass.Execute. Basically it would then look something like:

      Dim myClass as New DBClass(aString, commandType, connectionString)
      myClass.AddParam(name, DBType.Int, value)
      Dim result = myClass.Execute ' Or myClass.ExecuteASync!
      ' Do stuff with the result.

      Another example of stuff that just screams for an extra layer around it is the whole printing process. Have the PrintDialog, PrintPreviewDialog, PageSetupDialog, PrintDocument, maybe PrinterSettings, the whole event thing... I just want to say:

      Dim p as New PrintClass(document)
      p.Print ' Or, once again, p.PrintASync! ;)

      At this point, is anyone really disagreeing with me? Or do you really agree and know some other stuff that just calls to be put away in a programmer friendly class? :)

      It's an OO world.

      N Offline
      N Offline
      Nitin Singh India
      wrote on last edited by
      #22

      Its a simple design pattern named as "Facade" There are low level functions available in an API, but you might need to expose simpler interfaces to your "common" users; those who need very generic functionality. For specific cases, the users may take the pain of going deeper, but 95% of time, its not required. Hence wrapping an intricate functionality into a simple API (the target of Facade design pattern) provides both common as well as specific users the level of functionality desired by them. OOPS has lots to learn, and the more experience you get, the deeper you can think. Its good you want to get into design in 6 months and you would sure grow up to a happy professional :) Cheers (BTW: include design patterns in your quest, they would tell u a lot how things are designed)

      Sander RosselS 1 Reply Last reply
      0
      • N Nitin Singh India

        Its a simple design pattern named as "Facade" There are low level functions available in an API, but you might need to expose simpler interfaces to your "common" users; those who need very generic functionality. For specific cases, the users may take the pain of going deeper, but 95% of time, its not required. Hence wrapping an intricate functionality into a simple API (the target of Facade design pattern) provides both common as well as specific users the level of functionality desired by them. OOPS has lots to learn, and the more experience you get, the deeper you can think. Its good you want to get into design in 6 months and you would sure grow up to a happy professional :) Cheers (BTW: include design patterns in your quest, they would tell u a lot how things are designed)

        Sander RosselS Offline
        Sander RosselS Offline
        Sander Rossel
        wrote on last edited by
        #23

        Thanks for your reply. Actually this topic is already a few weeks old. I have read up on various OOD principles and design patterns and it already helps me in day to day coding. I have not looked into the Facade Pattern a lot yet, but I will certainly do so. The problem with this pattern for me is where do you keep the line between abstract and real implementation. It seems really hard to make a Facade Class 'Closed for Modification, but Open for Extension.' ;)

        It's an OO world.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups