473,382 Members | 1,180 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

.Net Classes Best Practices

Hello Everyone and thanks for your help in advance. I
have read a great deal about code reuse and the
development of the three-tier application, but am
somewhat confused on some issues and am looking for
input. I typically develop web applications in Visual
Studio 2003. Within the project, you can obviously
develop classes via code behind as well as other classes
not directly linked to web forms. However, it appears
that many examples actually recommend developing separate
class libraries that can be referenced from the web apps
as well as other applications. Could someone shed some
light on what is considered the best way to implement
this architecture. Any feedback is greatly appreciated.
Thanks.
Jul 21 '05 #1
2 1637
I guess the best way to think of it is in terms of seperation of layers.
For instance, let's say that I have a bunch of code in the code-behind
wherein I access a database and fill a grid. Now, if I want to change the
functionality of my query, I need to recompile that page and project and
re-deploy. This is because my presentation layer is in effect my dataaccess
layer. Now, if I do nothing in the presentation layer other than call a
function in my component, where myComponent.GetDate returns a DataTable, I
could simply use myDataGrid.datasoure = myComponent.GetData.

I can split the component up and put it on another server. I could
similarly have my component call a web service. So, my Component might
sit on a machine that has permissions to my DataBase server, but my web app
doesn't. It does however have access to this component or web service. I
can make my app more secure, more flexible, and depending on the situation,
get better performance. This is a very oversimplified example, but the
bottom line is the seperation of logic. Similarly, I could have my
Component App access a StoredProcedure to fill the datatatable which it
returns to the UI. Now, if I need to change something, I can simply change
the Stored Proc, realtime and implement my change transparently (well, as
transparently as you can). Now, I can give my StoredProc the permissions to
execute everything, but not the app itslef. I give the component
permissions (via the user credentials) to execute the Stored Proc(s) but
nothing else. Now, I have my logic split between the UI, my component and
the backend. I can create a very flexibily app here that's much more secure
than if I had to give my UI all the permissions....Similarly, my component
could call a web service, which in turn calls the proc. This adds one more
layer of complexity, but it allows me one more level to secure the app, move
things around without disturbing the UI code etc.

Overall, if you have a stable system, each time you do a new build, you run
the risk of injecting a new bug. So, by using components and splitting
things up, you minimize what you can break when you make a modification.
Certianly you still break things, but the more things are components, like
LegoBlocks, the more flexibility you have. You have a slow server or one
that needs to grow.....move the .dll to a new server, change the reference,
and off you go.

I want to emphasize that there's more to consider depending on the
complexity of your app, but the 'short answer' of it is that the more you
break seperate your functionality, the more your app can bend to changing
needs.

HTH,

Bill
"Hugh McLaughlin" <an*******@discussions.microsoft.com> wrote in message
news:08****************************@phx.gbl...
Hello Everyone and thanks for your help in advance. I
have read a great deal about code reuse and the
development of the three-tier application, but am
somewhat confused on some issues and am looking for
input. I typically develop web applications in Visual
Studio 2003. Within the project, you can obviously
develop classes via code behind as well as other classes
not directly linked to web forms. However, it appears
that many examples actually recommend developing separate
class libraries that can be referenced from the web apps
as well as other applications. Could someone shed some
light on what is considered the best way to implement
this architecture. Any feedback is greatly appreciated.
Thanks.

Jul 21 '05 #2
> I want to emphasize that there's more to consider depending on the
complexity of your app, but the 'short answer' of it is that the more you
break seperate your functionality, the more your app can bend to changing
needs.
Let's emphasize a little more. The more you add to functionality that isn't
going to be used, the less reliable your application is going to be.
A lot of .NET gurus, MVP, authors sit around writing little piece of code
for books. magazines and small desktop problems...some might even do a
"LITTLE" consulting work for a company...but when it comes down to
*production* code and actually doing all of the coding and realizing how
hard it is to manage the layer approach that isn't even utilized, you need
to ask yourself if these Microsoft Super "lost" architects actually spend
their time actually maintaining the code itself.

In other words, most of the the n-Tier features are never practical in the
REAL world. All that money that's being spent on architecting a n-Tier
layer for the database could have been spend on just buying a SQL server
database and doing the port. That's how many hours(read MONEY) of design
work is needed for n-Tier...and guess what? This 2-second change for the
long term is NEVER realized cause they then blame the customer for not
including it in the specifications and then take 2 months to do a major
redesign anyway in order to implement it anyway...whew!!!! lots of savings
there....

Oh and guess what? Remember ASP and COM object...all that separation stuff
in the old world of VB6. You have to use InterOp and that's SLOW. So all
this B.S. about porting never comes true with the NEXT BIG thing cause the
THING is SO DIFFERENT anyway, the legacy code will have some major
disadvantage anyway as someone trained in the legacy code is needed to
support it.

Oh and one more things, since you build WEB apps, consider asking yourself
what TRUE and REAL business advantage it will be to have the exact same
thing on Windows? and is this FEATURE that windows offers a critical
business feature that can't be done some way on the web? In other word, take
away this feature that windows offers and see if anyone really needs it ir
misses it. (Delayed order submission when disconnected from the internet or
the database? Is that really going to make difference in the quartely
statement when the saleperson is just going hook up at the end of the day
anyway? If the customer wanted it that fast and wanted real-time quotes,
they should order on the web in the first place!!)

You know things are so much easier to develop once you standardized on a
single browser, like IE versus Netscape. Even on customer support that's so
much easier. Now you got these same n-Tier, OOP guys forgetting that
important lesson....Remember to add in all the additional support and
maintenance costs in creating both a Windows and Web app that target the
same info.
"William Ryan" <do********@nospam.comcast.net> wrote in message
news:eB**************@TK2MSFTNGP11.phx.gbl... I guess the best way to think of it is in terms of seperation of layers.
For instance, let's say that I have a bunch of code in the code-behind
wherein I access a database and fill a grid. Now, if I want to change the
functionality of my query, I need to recompile that page and project and
re-deploy. This is because my presentation layer is in effect my dataaccess layer. Now, if I do nothing in the presentation layer other than call a
function in my component, where myComponent.GetDate returns a DataTable, I
could simply use myDataGrid.datasoure = myComponent.GetData.

I can split the component up and put it on another server. I could
similarly have my component call a web service. So, my Component might
sit on a machine that has permissions to my DataBase server, but my web app doesn't. It does however have access to this component or web service. I
can make my app more secure, more flexible, and depending on the situation, get better performance. This is a very oversimplified example, but the
bottom line is the seperation of logic. Similarly, I could have my
Component App access a StoredProcedure to fill the datatatable which it
returns to the UI. Now, if I need to change something, I can simply change the Stored Proc, realtime and implement my change transparently (well, as
transparently as you can). Now, I can give my StoredProc the permissions to execute everything, but not the app itslef. I give the component
permissions (via the user credentials) to execute the Stored Proc(s) but
nothing else. Now, I have my logic split between the UI, my component and
the backend. I can create a very flexibily app here that's much more secure than if I had to give my UI all the permissions....Similarly, my component
could call a web service, which in turn calls the proc. This adds one more layer of complexity, but it allows me one more level to secure the app, move things around without disturbing the UI code etc.

Overall, if you have a stable system, each time you do a new build, you run the risk of injecting a new bug. So, by using components and splitting
things up, you minimize what you can break when you make a modification.
Certianly you still break things, but the more things are components, like
LegoBlocks, the more flexibility you have. You have a slow server or one
that needs to grow.....move the .dll to a new server, change the reference, and off you go.

I want to emphasize that there's more to consider depending on the
complexity of your app, but the 'short answer' of it is that the more you
break seperate your functionality, the more your app can bend to changing
needs.

HTH,

Bill
"Hugh McLaughlin" <an*******@discussions.microsoft.com> wrote in message
news:08****************************@phx.gbl...
Hello Everyone and thanks for your help in advance. I
have read a great deal about code reuse and the
development of the three-tier application, but am
somewhat confused on some issues and am looking for
input. I typically develop web applications in Visual
Studio 2003. Within the project, you can obviously
develop classes via code behind as well as other classes
not directly linked to web forms. However, it appears
that many examples actually recommend developing separate
class libraries that can be referenced from the web apps
as well as other applications. Could someone shed some
light on what is considered the best way to implement
this architecture. Any feedback is greatly appreciated.
Thanks.


Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Hal Vaughan | last post by:
I think a lot of this is definately a question of personal programming style, but I'm new to Java and would like to hear a few opinions. I'm writing a control panel for an application that runs...
1
by: Miranda Evans | last post by:
Seeking reference material (a url, a book, an article) that offers advice and guidelines for organizing classes within files. For example, assume two classes: 1) SuperABC - a superclass 2)...
4
by: Robert Zurer | last post by:
I notice that Microsoft puts their interfaces and classes in the same assembly. For example System.Data contains OleDbConnection and IDbConnection etc. I have found it useful to keep my...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
1
by: Vincent V | last post by:
Hey i am just starting a new project and from the start i want to make sure my app is as Object Orientated as possible I have a couple of questions in relation to this Question 1: Should i...
4
by: Janus Knudsen | last post by:
Hello... Need a little explanation! Snippet from MSDN: "The following recommendations will help you use the classes contained in System.Net to their best advantage: Use WebRequest and...
2
by: Hugh McLaughlin | last post by:
Hello Everyone and thanks for your help in advance. I have read a great deal about code reuse and the development of the three-tier application, but am somewhat confused on some issues and am...
3
by: _DD | last post by:
I believe Balena's Best Practices book suggests grouping quite a few classes into each namespace. I don't remember a number, but this has me curious about how other programmers handle this. If...
37
by: pochartrand | last post by:
Hello, Is there a way to manipulate or at least read the pseudo-class of an element ? I know the style attribute can be accessed and gives the CSS properties for a particular element....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.