What is better in c#?

Posted on 2009-07-06
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
Question by:hazemfadl
  • 2
LVL 13

Expert Comment

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

DRY :'t_repeat_yourself
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.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.
LVL 13

Accepted Solution

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

We have


Then for products we use

Each with

for unit tests

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 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