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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

624 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