473,219 Members | 2,011 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,219 software developers and data experts.

truly-optimized coding styles & design patterns in C#?

Hello All,

I'm always looking for ways to improve my code. Most of the time (whenever
I'm working on a project) I write a bunch of functions. Then after the
project is finished, I put all the similar functions into their own
module/class/page for neatness:
-- like a stringsManipulate class which has all string manipulation methods
to the project...separated from the whole project into its own library for
neatness.
-- like a databaseActions class (or code library) which holds all the
database methods to the project...also separated from the project into its
own library for neatness.

By the time my project is separated/sorted, it consists anywhere from 5-10
pages/libraries of functions so that everything is nice and neat.

However, there are never any delegates, factories, interfaces, extensions,
exceptions classes, none of that. Sometimes I have some error handlers but i
never have any of the other features I just mentioned. So, what i'm
wondering is...is all that fancy stuff really necessary? Or, is that just
something you need to worry about when you're working on something you know
millions of people will use (like some big business product or application
like AOL)?

I've been coding for several years now and I've seen many other people's
coding styles. One guy I knew I think created all his objects from scratch.
I've seen him code his own framework of factories, iterators, interfaces,
structs, event handlers, delegates, creating exceptions here, throwing
exceptions there, extending something there, implementing something here. It
looked very confusing and very time-consuming...yet efficient and neater than
the way I was doing things.

So what I want to know is...is this all fancy stuff necessary or any good
for small-medium website developments or desktop apps? And if so, are there
any links where I can learn the best design, strucutres, object models, and
the like?

I have been looking up some c# design patterns and there are many of them
have my mind going in circles. When coding normally, I never know when I
need to make exceptions, or interfaces, or events...My mind doesn't think
like that and I'm trying to find a place that will make me understand.

Usually I just write a function that does what I need to do and it works so
I take it, break it, and separate it for neatness. But somehow I feel that's
not enough. Somehow I feel I need to get my hands even dirtier and create my
own framework of factories and all those other concepts I can't really
understand. But is it really worth it? And would small web development &
desktop application stuff really have a great improvement in speed and
cleanliness? Well cleanliness I can see...speed I'm not sure of...I guess so?

Hope some of you can help me out. Thanks for reading.

Nov 16 '05 #1
1 1669
R,

Your honesty (and courage!) are refreshing.

The first thing I would say is that you are to be commended for your
pragmatism. Don't change it. Use what works, yet be curious about ways to
improve it. In that sense you are exactly on-track.

My sense is that you may have a background in structured programming and
haven't quite had your "aha" experience yet with OOD. I would focus on
grokking design patterns but try to find practical examples of each pattern
that you can relate to. I admit, that's easier said than done since far too
many writers fail to provide practical rationales and examples. But with a
fair bit of Googling you can usually some up with something.

Also, consider looking at "anti-patterns" -- things not to do.

Another thing you can do to expand your mind is to learn a new language now
and then. Each one has its own ways of approaching the problem domain and
comparing and contrasting how they work gives you a deeper understanding of
concepts. Sometimes you see that features or concepts that are terribly
important in language X are less important in language Y because of
something inherent in the language, not necessarily something inherent in
OOP. Personally for example I'm pecking away at Ruby right now and find it
rather mind-expanding after two and a half years of steady C# coding.

You are right not to feel obligated to use every feature just because it's
there. Start by naming your number one maintenance headache in the many
apps you've written and seek out the simplest and most elegant ways to
mitigate that problem first.

As to your question whether "all this stuff" is just for "big projects" --
I'd give you a qualified "no". There are often different trade-offs in,
say, creating a small utility app vs coding something that has to fit into
an Enterprise framework vs something destined for commercial release. But,
good design is good design and the best design ideas tend to be generally
applicable to most any non-trivial project.

It's hard sometimes to find the balance between some theoretically "best"
way and the messy real-world demands of deadlines and marketing droids and
so forth. The way you describe the acquiantance who was whipping up all
sorts of elaborate and elegant "software souffles" might be describing some,
any, or all of the following:

1) A really expert guy working "in the zone"
2) Someone trying to build an app that only he can maintain
3) Someone constructing a monument to their ideal of the perfect program, at
the expense of practical matters

I'm a little worried that he creates "everything from scratch". Surely he
has a body of existing work that he leverages as a starting point! If not,
why not?

Does this guy have a track record of producing stable software on time that
the customer is happy with? Then emulate him -- especially if he documents
his work and can explain it coherently. Otherwise take him with a grain of
salt.

--Bob

"R Reyes" <RR****@discussions.microsoft.com> wrote in message
news:77**********************************@microsof t.com...
Hello All,

I'm always looking for ways to improve my code. Most of the time (whenever I'm working on a project) I write a bunch of functions. Then after the
project is finished, I put all the similar functions into their own
module/class/page for neatness:
-- like a stringsManipulate class which has all string manipulation methods to the project...separated from the whole project into its own library for
neatness.
-- like a databaseActions class (or code library) which holds all the
database methods to the project...also separated from the project into its
own library for neatness.

By the time my project is separated/sorted, it consists anywhere from 5-10
pages/libraries of functions so that everything is nice and neat.

However, there are never any delegates, factories, interfaces, extensions,
exceptions classes, none of that. Sometimes I have some error handlers but i never have any of the other features I just mentioned. So, what i'm
wondering is...is all that fancy stuff really necessary? Or, is that just
something you need to worry about when you're working on something you know millions of people will use (like some big business product or application
like AOL)?

I've been coding for several years now and I've seen many other people's
coding styles. One guy I knew I think created all his objects from scratch. I've seen him code his own framework of factories, iterators, interfaces,
structs, event handlers, delegates, creating exceptions here, throwing
exceptions there, extending something there, implementing something here. It looked very confusing and very time-consuming...yet efficient and neater than the way I was doing things.

So what I want to know is...is this all fancy stuff necessary or any good
for small-medium website developments or desktop apps? And if so, are there any links where I can learn the best design, strucutres, object models, and the like?

I have been looking up some c# design patterns and there are many of them
have my mind going in circles. When coding normally, I never know when I
need to make exceptions, or interfaces, or events...My mind doesn't think
like that and I'm trying to find a place that will make me understand.

Usually I just write a function that does what I need to do and it works so I take it, break it, and separate it for neatness. But somehow I feel that's not enough. Somehow I feel I need to get my hands even dirtier and create my own framework of factories and all those other concepts I can't really
understand. But is it really worth it? And would small web development &
desktop application stuff really have a great improvement in speed and
cleanliness? Well cleanliness I can see...speed I'm not sure of...I guess so?
Hope some of you can help me out. Thanks for reading.

Nov 16 '05 #2

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

Similar topics

4
by: ketulp_baroda | last post by:
Hi Global variables are not truly global in Python ; they are only global within a module namespace. I want a variable such that if i change its value in any module then it should be reflected in...
5
by: UJ | last post by:
Is there any number I can get that is truly unique for a computer that can't be changed? I want to have a system whereby I have a computer that accesses a web service based on some unique value...
1
by: News Server | last post by:
Any help appreciated. I have two Access tables, customer and orders. I would like to create a truly hierarchical xml file form the joined tables. I need to produce: <Query1> <Customer>...
1
by: Brian | last post by:
Hello all. Hope you're all enjoying your Christmas / New Years etc. I know i've asked this before but i am truly at my wit's end, so any help right now would be much appreciated! How do i...
41
by: Mark R. Dawson | last post by:
I have never used a goto statement in my code, one of the first things I was told in my software classes a number of years ago was "goto statements are evil and lead to spagetti code - do not use...
2
by: Don | last post by:
If you expose an object as a property in a VB.NET class, like so: public class MyClass private obj as NestedClass Public Readonly Property NestedObj as OtherClass Get return obj End Get...
23
by: Alvin | last post by:
Well, I'm developing a Tetris game in SDL, but when it comes to deciding the next block, I'm stuck. It's random, but when I try something like seeding the randomizer with the time, it won't update...
4
by: Mufasa | last post by:
I'm looking for a way to get a truly unique identifier for a machine for our client software. I'd like to have it so that there's little or no setup by the end user. (We set up the machines and...
114
by: Andy | last post by:
Dear Python dev community, I'm CTO at a small software company that makes music visualization software (you can check us out at www.soundspectrum.com). About two years ago we went with decision...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.