Solved

What is better in c#?

Posted on 2009-07-06
3
184 Views
Last Modified: 2012-05-07
Put connection string and some common function I use it in public class
Like {GetLastID , FillGrid,&}
Or put every function in its class
Note: I used N-tier (layer) at my work.
Thanks for help
0
Comment
Question by:hazemfadl
  • 2
3 Comments
 
LVL 13

Expert Comment

by:crazyman
ID: 24783800
Why on earth would you want to put the same function in every class, what if you need to change it.

DRY : http://en.wikipedia.org/wiki/Don't_repeat_yourself
0
 
LVL 18

Expert Comment

by:Richard Lee
ID: 24786635
Okay I believe in having Utility classes. An approach you can take is creating your own framework project so it can be consumed within any of your tiers. For example

Company.Framework
Company.Application.Business --> uses Company.Framework
Company.Application.Data --> uses Company.Framework
Company.Application.Presentation --> use Company.Framework

Within your framework project you can different Utility classes that assist with different things for example serialization, data access, string manipulation, etc. Now it absolutely doesn't make sense for a class to have one method, that's not to say that a class cannot have one method if that's the only one that's relevant.

Group related functions in the same class.
0
 
LVL 13

Accepted Solution

by:
crazyman earned 50 total points
ID: 24793025
I agree with DaTribe

We have

Company.Core
Company.Data
Company.Web
Company.Web.UI



Then for products we use
Company.ProductName.Business
Company.ProductName.UI
Company.ProductName.Data
Company.ProductName.Services
etc...

Each with
Company..ProductName.Business.Tests

for unit tests
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now