Click here to Skip to main content
15,892,965 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey guys,

I am working on my first layered application right now. I have the 3 standard Layers, Presentation, Business Logic and Data Access. Also I have a Shared Layer, which consists of some Attributes, Helper classes and the like and also my actual Business Objects so they can be used through all Layers.

I am using simple textfiles as database, no SQL Database or the like, and only need to read in and write out full files. My Data Access Layer knows how to map my Business Objects to a file and back. My Business Logic Layer forwards Load/Save functionality by using the Data Access Layer through Interfaces and applies some rules. The Presentation Layer consists of my Forms and uses the Business Logic Layer to get my BOs and populate controls. Does this sound right to you guys?

Also I am not really sure where to put some stuff:

1. The User can access a file from a Local source, or alternatively through a file server. Basically I am downloading the file temporary and then load it into my program. What Layer should that FTP access happen in? Would my BOManager offer SaveLocal/LoadLocal and SaveOnline/LoadOnline methods and use my FTPClient class. Or should I create 2 several Manager classes? Or would FTP access belong into my Data Access Layer? I know I maybe am thinking too much on this, but well, want to learn the right ways as early as possible.

2. There has to be some information around whether the User has already specified a file name and location, so my program can use those Information after the first save. Would I put such stuff into my Business Logic Layer or UI?

3. My BOs hold values which I want to output with different units. For example I have a temperature value. The user will have the option whether he wants to use °F or °C. Internally I always want to store it as Kelvin. Where would I put the Logic to convert those values?

4. I am working with some .ini files to setup my program. Does reading/writing them also count as Data Access? Should I create several classes for managing several different structured .ini files, or just one?

Excuse my bad english and explanation skills please... Hope someone can help me.
Posted

1 solution

Choose who is responsible.

As an example on temperature: The business is very clear about it. It only wants Kelvin. But, just let the user choose the unit he/she prefers to enter values in the front-end. This also makes very clear that the front-end is responsible for providing the business layer with the correct data and therefor must convert it from whatever into Kelvin.

For FTP, I personally wouldn't make business responsible for specific technology like FTP or whatever method of transporting files. Today it is FTP, tomorrow something else. The business layer should only worry about business matters and not about specific technology implementations. In this case the big question would be, does your business really care about FTP?

Good luck!
 
Share this answer
 
v2
Comments
Patrick Epting 29-Jan-14 8:42am    
Thanks for your reply.

For the unit conversion I have now created an "IValueConverter" interface and an attribute "Value" which I can apply to a property of my business object. My UI then checks if the "Value" attribute is set on a property, and if this is the case uses the injected ValueConverter object to, for example, convert from kelvin to celsius when getting, and other way round when setting the property. Not exactly beautiful, but those the job for now.

For the FTP/DataAccess part: Well, the implementation of my FTPClient sits in the Data Access Layer, but the Business Logic uses it to through an interface for Down/Uploading files and the like. Maybe explained that a bit wrong. For example it first calls iFileTransfer.DownloadFile(filePathOnServer, filePathLocal) and then iBORepository.Load(filePathLocal). Is this okay?
E.F. Nijboer 31-Jan-14 6:14am    
If it is designed and has a good idea behind it, it should be all okay. I would personally not favor sending it to a local path and then upload it again but sure that could work.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900