Reputation: 5522
Gday guys. Clearly im an amateur at programming, but am learning!
I want to create a simple asp .net web site that basically is a very small database for repair jobs that we have going on in our office.
I am uncertain of a few things: Firstly, how do I structure my classes?
I know I will have a job class that will have properties such as name, issue description, technician etc and also have methods for loading certain jobs into that instance. But if I have a page that will search for all jobs, where abouts would that method that returns ALL jobs lie? I can't really see it going into the Jobs class, as the Jobs class really only deals with a single instance of a Job, and not multiple jobs. Do I have to have a separate class called Jobs that has the methods for getting ALL jobs?
Second question- if I have methods that retrieve data from a database, what is the best type to return this to the calling class? A List? A DataSet?
Finally, should I again have a separate class for the data access and a separate class for the business logic type stuff for Job?
I know I might be looking into such a simple application too much here, but I want to get myself into the habits of using the RIGHT techniques from the start..!
Looking forward to haering your advice!
Upvotes: 1
Views: 254
Reputation: 844
1) Refactoring by Martin Fowler realy helped me grasp OO programming. It can teach you not only to refactor your classes, but what to look for when designing them.
In your example, the method that returns all jobs will go in to the class that holds the list of jobs. Stay away from creating a List<Job>
, create a single instance of a class that holds a List<Job>
.
2) Stay away from DataSets unless you know exactly why you need to use one. I suggest you use WCF + Linq to fetch data from your database as a list of your own class.
3) WCF + Linq will take care of your data access layer. Your own classes will be your busness logic layer. Finaly you will benefit from an addition View layer for your interface.
Upvotes: 2
Reputation: 24192
Visual Studio provides sample projects, that you can create by using the New Project option... It can create a fully working web application, so that you can start learning from it.
You can try MVC. Create a new MVC project and it will ask if you want it to be empty, or if you want to create a sample project with working code... of course you should take the second choice... after that you can run the application and see what happens! =)
Then you can start exploration... try changing things in this project. And question about everything you don't understand. StackOverflow is a good place, as you may have noticed.
Upvotes: 2
Reputation: 20643
Upvotes: 1