|
3-Tier architecture can be of great help. If you are developing with .NET then this will become 4-Tire architecture: User Interface, Code Behind, Business Layer, Data Access Layer. Do not make the mistake and design your application architecture exactly the same as database. Remember this, which I read in some text somewhere:
Object oriented programming is not about normalizing data but normalizing behavior.
You know ahead of time you will be interacting with the database so perhaps create utility classes which take a query and execute it, return tables, data readers etc.
Store your connection strings in the .config file.
The only part of your code which should realize this is a web based application is the User Interface and Code Behind files. The rest of your code should be totally ignorant of whether this is a desktop, web or mobile application. This will help in debugging, maintenance etc.
Good Luck!
CodingYoshi
Artificial Intelligence is no match for Human Stupidity.
|
|
|
|
|
CodingYoshi wrote: Do not make the mistake and design your application architecture exactly the same as database.
Hi Yoshi,
can you please explain what you do you mean here?
Thanks
shank
|
|
|
|
|
I have seen people create classes based on database tables but it is not a good practice. For example lets say I have the table s below:
Customers
Orders
Since this is a many to many relationship, to normalize we will create another table called:
CustomersOrders
This is basically the bridging or link table. Now design classes based on these tables and your design is as below:
Customer Class
Orders Class
CutomerOrders Class
You see what I mean. Instead you should have the following classes:
Person
Customer : Person // If later you need employee you can Employee : Person
// Customer should also have an OrderCollection. Remember Aggregation
Address // Both the Customer's shipping and billing address can use this
CustomerCollection
Order
OrderCollection
You will have classes which have methods for performing CRUD operations on these objects and those classes might call other classes for help. You might have many other properties and methods in your Customer class, in addition to the fields in the database, for example, FullName (First Name + ", " + Last Name), GetPendingInvoices() etc.
Do you see now what I mean?
OrdersCollection
CodingYoshi
Artificial Intelligence is no match for Human Stupidity.
|
|
|
|
|
Thank You very much Yoshi for your useful information.
I highly appreciate it.
|
|
|
|
|
I'm searching for UML design tool that is also capable of generating and reverse engineering C#. Integration with Visual Studio would be great also. Any suggestions?
For those of you who are familiar with ModelMaker, can you please make a quick comparison with other tools known to you. I used ModelMaker for Delphi Win32 projects a while ago, and it was best choice.
|
|
|
|
|
Enterprise Architect[^] by Embarcadero seems to be gaining good reviews from users. You might want to look into that.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Enterprise Architect looks really impressive. I have tested it, and it's on my shopping list now
Thanks Pete!
|
|
|
|
|
Pete O'Hanlon wrote: Enterprise Architect
I agree, it is a good one. Do you know of any open source ones? Doesn't have to be as good, but something to fiddle with.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Hi!
I am not sure where should I post this topic. I just need an idea about my task below
a central server polls from a legacy server for media updates. the media file has incremental file name i.e 1.mpeg, 2.mpeg and so forth. central server needs to poll the legacy server and check for update via ftp. once it finds update it needs to copy the files and bring into central server from legacy server and distribute to its 600 clients. each client plays those mpegs constantly and central server needs to update the content in clients playlist automatically. for example clients current playlist could be
1.mpeg
2.mpeg and so forth. how do i keep adding the updated file to the play list and keep deleting if the files are more than 20 i.e.
play 1-20 and as soon as it hits 21 delete old files
please help i dont know how to acheive this and which what program.
thanks in forward.
please just give me an idea how to achieve this
|
|
|
|
|
|
You have issues to resolve;
1- How to get latest file from FTP?
2- How to add it in playlist and keep thecount up to 20?
Ans 1- You can use a windows service to keep on checking the FTP location for any new file avaialble. If you get any updates using some FTP client you can download it.
Ans 2-
a) Adding newly downloaded file in the playlist depends mostly on the player that you are using. There should external functions avaialble to call.
b) This has some trick. Its like a queue where you can not hold more than 20 items. Use simple arraylist for the files to hold and when the count goes up, remove the top 1.
You can start with this.
|
|
|
|
|
Hi All,
I am designing a ticket booking system with seat selection facility. I need to store the Seating Map (of an auditorium/theatre) in database so that the same can be fetched and shown in UI.
I am not sure how to do the same in an RDBMS. Please help me.
Thanks
Riyaz
|
|
|
|
|
hmrizin wrote: Please help me.
With what exactly? The design, the implementation in the RDBMS, fetching the things or showing the stuff in the UI?
A quickstart; them seats are probably numbered. You need a table to store who is sitting on what number on a specific event. A theater can have multiple events on a day, so you'd also need a table to list the events
I are troll
|
|
|
|
|
Eddy Vluggen wrote: With what exactly? The design, the implementation in the RDBMS, fetching the things or showing the stuff in the UI?
The implementation in RDBMS.
The Database Design should support the following:
1. Storing Seating Map of different Auditoriums/CinemaHalls
2. Should store not only the seat numbers but the exact seating arrangement with pathways, screen-location etc
Is is possible to do with an RDBMS? Please gimme some ideas.
Thanks
Riyaz
|
|
|
|
|
hmrizin wrote: Is is possible to do with an RDBMS?
Yes. Have you ever designed a database before?
I are troll
|
|
|
|
|
|
If you can do it in MySQL, then you can do it in SQL Server too
I doubt that you'll run into problems with grouping the data over tables and normalizing them, although you might run into some minor problems with the differences in syntax between SQL Server and MySQL.
To answer the original question; yes, it should be possible.
"please help in this regard. give the visual basic code for this as soon possible."
|
|
|
|
|
Sorry for the late reply Eddy; caught up with some other work
Thank you for your support.
Have started designing the database. Will keep you posted.
|
|
|
|
|
No problem, good luck
What sig?
|
|
|
|
|
Should applications, which are for solely reporting purposes, rely on stored procedures or should the logic for the report be done on the app side? For example, if I need:
Employees who have worked on Tuesday at least 5 out of 9 weeks prior to DateX, and also worked day after DateX, and have worked more than 90 days in the past 12 months
If no DBA's are involved and I am the only developer, I can either
1. Write a stored procedure which will return the employee records which fit the above criteria OR
2. The client can get all the Employee records from the Employee table and Hours from the Hours table for the past 12 months and then perform the search for the criteria on the client side
Which option is better? How much business logic should we write on the db side--is there really any limit or convention?
CodingYoshi
Visual Basic is for basic people, C# is for sharp people. Farid Tarin '07
|
|
|
|
|
You won't be limited to client-side searching if you avoid sprocs. Clientside searches can also be initiated from inline SQL.
CodingYoshi wrote: Which option is better? How much business logic should we write on the db side--is there really any limit or convention?
There are several, some of them are being defended religiously. I'd recommend using dOOdads or LINQ.
dOOdads has the advantage that you can use the MyGeneration application to generate the framework and sprocs, and place the business-logic in the predefined BL-layer. For bonus-points, put the BL in it's own DLL.
LINQ has the advantages of simplicity and elegance.
--edit--
CodingYoshi wrote: Employees who have worked on Tuesday at least 5 out of 9 weeks prior to DateX, and also worked day after DateX, and have worked more than 90 days in the past 12 months
These go by preferation in the database; if you decide to write another frontend (web, or a newly purchased control-library) then you'll already have your (by then already tested) BL in place. This also avoids duplication of the code.
You got multiple ways to implement this. From a trigger, using a RaiseError (with a low severity, or it will close the connection) to fire an event back to the UI. You could also use a sproc that returns a message or an error-id; I personally prefer to raise a non-severe error.
Those things that can't be caught in the conceptual model of the database go in the BL-layer of your application. Those are the BL-rules that state to send a twitter-message or shut down a remote workstation.
I'm curious to the other answers that will appear on this question
I are troll
modified on Wednesday, July 8, 2009 8:57 AM
|
|
|
|
|
Thanks. I understand I can use LINQ but my question is whether to put the logic within the stored procedure or put it in the DAL (using LINQ) or whatever else.
Anyone else?
CodingYoshi
Visual Basic is for basic people, C# is for sharp people. Farid Tarin '07
|
|
|
|
|
I think the answer is, it depends. There are arguments for and against using stored procs.
Arguments for:
(i) A stored proc may well perform better. Dragging lots of data out of a database across a network onto an app server for further processing may well be a slow operation. Moving the logic down into the stored proc means that you are processing the data at source, without the need to transfer it across the network, which can sometimes be a big saving.
(ii) the stored procedure logic can be reused from several different clients. Maybe you have one application written in VB, another in Java, both needing to access this same summary data. If you put all that logic into a stored proc, you only need to write it once.
Arguments against:
(i) SQL is not a procedural language. You can sometimes find yourself struggling with cursors and loops and temporary tables trying to work around the limitations of SQL. In those cases you might be better off doing it in the high level language of your choice (C#, Java, VB, Ruby, Python, whatever) where this sort of complex logic is easier to code. (Some modern databases let you write your stored procs in a language like C# or Java, which changes the landscape somewhat.)
(ii) Some development shops like to minimise the number of languages they have to learn and support. This is particularly true if people are using some sort of data abstraction layer so that programmers are hidden from having to know SQL (LINQ, Hibernate, iBATIS, ActiveRecord, etc). Putting some of the logic into C# (or whatever your language is) and some into SQL means that either one developer has to know both languages, or the work is now split across two developers (who have to coordinate to make sure they are working in line with each other).
I can't tell you which option to use for your application because I don't know enough about your requirements, your development environment or even your personal taste, all of which play a part in the decision.
|
|
|
|
|
I'm prejudiced - need to get that out of the way first. I alway put the logic for a report in the stored proc, this for and I can make TSQL sit up and beg.
Having said that I would not consider this a report, unless the structure of the request is stable which I don't think this one is. This, to me, is more of an analysis issue. I want to get at the database and find these type of people.
We use SSRS and have a base rule NO intelligence in the report other than setting the parameter for the proc to use. Having said that the rule is flexible, any business will have a requirement that just has to be met and then we build a report just for that requirement and the logic could be anywhere that suits the developer.
This type of request from a user would not even make it to the report development stage. We use ActiveQueryBuilder[^] and RadarSoft[^] cubes to give the user access to the data. Both have been wrapped up and get referenced by our apps.
Radar Soft has a fairly steep learning curve but is well worth it. Query builder is just TSQL in the UI. I do not allow a set of key words to be passed in and they only have RO access to the database. these also allow us to implement another rule, no report longer than about 2 pages - the rest is a data dump.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks for the answers, it really has helped!
After some research I have gathered the following:
I think if the logic is not too complicated, the developer is comfortable with sql scripting, and has access to work on the db side then sometimes it is better to put the logic in the stored proc. This, just as David has pointed out, saves us the cost of transferring huge amount of data across.
However, if the data is not simply for reporting purposes but it also might be updated, deleted etc. then it is not a good idea. Furthermore, we always have to be aware that if the app is to be installed on mobile device then we can not use the code because some compact database providers do not support sql stored procedures, for example, SQL CE. The other disadvantage is if we want to know why an employee did not qualify (did not work on Tuesday etc.) then things become a little messy. I mean there are still ways to get around it but they are not the best.
CodingYoshi
Artificial Intelligence is no match for Human Stupidity.
|
|
|
|