Recent

Author Topic: GUI, bussiness and data layer separation  (Read 2348 times)

zobook

  • New member
  • *
  • Posts: 7
GUI, bussiness and data layer separation
« on: June 18, 2014, 09:32:28 pm »
I hope my English is good enough to be understood. I'm making a program for myself, for fun and as a learning experience. Is a front-end for a dedicated retro-gaming machine (mame, nes, genesis and so). I made a similar program in practically every language i learn in the past (Turbo Pascal 7, Visual Basic 3/5, Delphi 3/7) and now I'm starting to use Lazarus and wanted to try the separation of GUI, business and data layer but I'm not sure how to do it. Right now i have a TFrontEndLayout class that knows where and how draw everything (the game list, the name of the system, the screenshot, etc) a TFrontEndState class that let me access the list of systems, games, emulators and execute the programs accordingly. I also made a TSuperList class (i don't want to mess around with "serious" databases for such a simple application) that uses TAB delimited text files to hold the information and finally the user input (keyboard or gamepad) is managed directly in the Form with a TJoystic class to help.

How much does a class has to know about the others? Should i create an aditional class to manage the data stored in the TSuperList instead of managing it directly from within the TFrontEndState?

But that additional class must have a lot of information belong to the business class or I'm wrong?

I hope this is clear and not a mess.

Thanks in advance for any help the forum people can give me.

Fernando

Leledumbo

  • Hero Member
  • *****
  • Posts: 8833
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: GUI, bussiness and data layer separation
« Reply #1 on: June 19, 2014, 01:38:42 pm »
Quote
How much does a class has to know about the others?
As much as it needs
Quote
Should i create an aditional class to manage the data stored in the TSuperList instead of managing it directly from within the TFrontEndState?
But that additional class must have a lot of information belong to the business class or I'm wrong?
Depending on your definition of "managing". It's fine for TFrontEndState to access TSuperList methods and properties directly.

zobook

  • New member
  • *
  • Posts: 7
Re: GUI, bussiness and data layer separation
« Reply #2 on: June 19, 2014, 10:56:42 pm »
Now the TFrontEndState has a private TSuperList fields for each list (games, emulators and so) and access TSuperList methods like Count to know how many items, Field to get the "file_path" field of item #12 in the games list. At some point i try the "middle man" between TFrontEndState and TSuperList but now i think that drop that and incorporate it to TFrontEndState was a good idea.

Thanks.

 

TinyPortal © 2005-2018