42 2201
Jon Skeet [C# MVP] <sk***@pobox.co m> wrote in
news:MP******** *************** *@msnews.micros oft.com: Chris LaJoie <ch***@etriptra der.com> wrote: > Partials are just stupid
I couldn't disagree more. In our project, we have a class that's approaching 7000 lines of code. This gets to be a problem when we have 2 or 3 people who want to work on the file at the same time. It'd be so much easier with partials.
That sounds like a really bad reason to use partial types, IMO. Is it really not possible to refactor that code into more classes which would increase the readability of the code to start with? I've only *very* rarely seen classes which really deserve to be that long.
A class should be a logical element in the structure of the system.
Not a way to cut up code because a random person cooked up the idea that a
file of XYZ lines is too large. After all, cutting up a class in multiple
classes pollutes the class hierarchy with extra types that are hardly
different, creating extra problems when the types require each-others
data/logic (they were first stored in the same class, remember ;) ).
Although 7000 lines is a lot, you sometimes end up with large
classes, for example a main form class which controls all child windows
and main gui application logic (not the core application logic). It can
become very messy when you are chopping that up in smaller classes, which
will be used in just 1 spot: the main gui form, but because they're other
classes, you have add overhead code to communicate with them to reach
their data.
FB
--
Get LLBLGen Pro, the new O/R mapper for .NET: http://www.llblgen.com
Frans Bouma <pe************ ******@xs4all.n l> wrote: That sounds like a really bad reason to use partial types, IMO. Is it really not possible to refactor that code into more classes which would increase the readability of the code to start with? I've only *very* rarely seen classes which really deserve to be that long. A class should be a logical element in the structure of the system. Not a way to cut up code because a random person cooked up the idea that a file of XYZ lines is too large. After all, cutting up a class in multiple classes pollutes the class hierarchy with extra types that are hardly different, creating extra problems when the types require each-others data/logic (they were first stored in the same class, remember ;) ).
I agree that a class should be a logical element - but I've rarely seen
a single element of that many lines which isn't better broken down into
smaller subelements. That's not to say it should be done artificially,
of course.
Although 7000 lines is a lot, you sometimes end up with large classes, for example a main form class which controls all child windows and main gui application logic (not the core application logic). It can become very messy when you are chopping that up in smaller classes, which will be used in just 1 spot: the main gui form, but because they're other classes, you have add overhead code to communicate with them to reach their data.
If it controls *all* the child windows, I would have thought that would
be too much - each child window should have its own class, I'd imagine.
Maybe I'm misunderstandin g you though.
For what it's worth, I've been in a similar situation with all the GUI
logic for a mobile web application being in one class (this was written
a few years ago). Having started down that road, it's very difficult to
refactor it into smaller classes (we've tried twice). If we'd started
off with the goal of factoring out different parts, I'm sure it
wouldn't have been too difficult though. (One of the main problems was
that it was originally going to be a small app, and then it grew much,
much bigger.)
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
If you look at the BCLs you will see a huge deep inheratence tree. Also a
reason why we dont have multpile inheratance.
(never could spell that word too :D)
Im sure if you look more abstract at youre class you will see places you can
break it up or generalise and derive, try a little normalisation:D
"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com... Frans Bouma <pe************ ******@xs4all.n l> wrote: That sounds like a really bad reason to use partial types, IMO. Is it really not possible to refactor that code into more classes which
would increase the readability of the code to start with? I've only *very* rarely seen classes which really deserve to be that long.
A class should be a logical element in the structure of the system. Not a way to cut up code because a random person cooked up the idea that
a file of XYZ lines is too large. After all, cutting up a class in
multiple classes pollutes the class hierarchy with extra types that are hardly different, creating extra problems when the types require each-others data/logic (they were first stored in the same class, remember ;) ).
I agree that a class should be a logical element - but I've rarely seen a single element of that many lines which isn't better broken down into smaller subelements. That's not to say it should be done artificially, of course.
Although 7000 lines is a lot, you sometimes end up with large classes, for example a main form class which controls all child windows and main gui application logic (not the core application logic). It can become very messy when you are chopping that up in smaller classes,
which will be used in just 1 spot: the main gui form, but because they're
other classes, you have add overhead code to communicate with them to reach their data.
If it controls *all* the child windows, I would have thought that would be too much - each child window should have its own class, I'd imagine. Maybe I'm misunderstandin g you though.
For what it's worth, I've been in a similar situation with all the GUI logic for a mobile web application being in one class (this was written a few years ago). Having started down that road, it's very difficult to refactor it into smaller classes (we've tried twice). If we'd started off with the goal of factoring out different parts, I'm sure it wouldn't have been too difficult though. (One of the main problems was that it was originally going to be a small app, and then it grew much, much bigger.)
-- Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
Jon Skeet [C# MVP] <sk***@pobox.co m> wrote in
news:MP******** *************** *@msnews.micros oft.com: Frans Bouma <pe************ ******@xs4all.n l> wrote: Although 7000 lines is a lot, you sometimes end up with large classes, for example a main form class which controls all child windows and main gui application logic (not the core application logic). It can become very messy when you are chopping that up in smaller classes, which will be used in just 1 spot: the main gui form, but because they're other classes, you have add overhead code to communicate with them to reach their data. If it controls *all* the child windows, I would have thought that would be too much - each child window should have its own class, I'd imagine. Maybe I'm misunderstandin g you though.
Child windows, for example in an MDI situation or docked inside the
main window, should control themselves, but say, the child window wants
something done in the application... where to put that logic, when yuo can
also start it from the menu for example... this will increase the main
form's code a lot and it's hard to chop it into multiple pieces because
you then end up with a lot of events, properties and other stuff that
wasn't even there in the beginning ;) exactly like you describe yourself:
For what it's worth, I've been in a similar situation with all the GUI logic for a mobile web application being in one class (this was written a few years ago). Having started down that road, it's very difficult to refactor it into smaller classes (we've tried twice). If we'd started off with the goal of factoring out different parts, I'm sure it wouldn't have been too difficult though. (One of the main problems was that it was originally going to be a small app, and then it grew much, much bigger.)
That's what I ment :) But I agree that developers should write
classes that do a certain thing and not control the whole universe.
However it's sometimes hard to make the decision: add it to an existing
class or create a new class. Decisions like that in the early start of a
project can make the difference between a small set of large classes vs. a
large set of small classes.
FB
--
Get LLBLGen Pro, the new O/R mapper for .NET: http://www.llblgen.com
Frans Bouma <pe************ ******@xs4all.n l> wrote: That's what I ment :) But I agree that developers should write classes that do a certain thing and not control the whole universe. However it's sometimes hard to make the decision: add it to an existing class or create a new class. Decisions like that in the early start of a project can make the difference between a small set of large classes vs. a large set of small classes.
Absolutely - but I'd usually prefer a large set of small classes, and I
*really* don't think that encouraging a small set of large classes is
something the language specification ought to be doing.
The main use of partial classes as far as I can see, however, is
keeping the machine-generated parts away from the human-generated
parts. That seems a perfectly reasonable thing to encourage.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Thanks, Eric. I don't suppose there's a list of changed sections anywhere,
or an MS Word diff tool I'm unaware of..
"Eric Gunnerson [MS]" <er****@online. microsoft.com> wrote in message
news:OD******** ******@TK2MSFTN GP10.phx.gbl... The first two should be identical, though the ECMA one has different numbering. The third one has some clarifications and updates, and a new introduction.
-- Eric Gunnerson
Visit the C# product team at http://www.csharp.net Eric's blog is at http://blogs.gotdotnet.com/ericgu/
This posting is provided "AS IS" with no warranties, and confers no
rights. "Mike Schilling" <ms************ *@hotmail.com> wrote in message news:eq******** ******@TK2MSFTN GP12.phx.gbl... "Eric Gunnerson [MS]" <er****@online. microsoft.com> wrote in message news:uh******** ******@TK2MSFTN GP09.phx.gbl... You may download the new specification at the C# Developer Center (http://msdn.microsoft.com/vcsharp/language). There is a discussion forum for the C# language on that same page.
I now have three C# language specs:
C# Language Specification (from Microsoft), dated 2001 ECMA-334, dated 2002 C# Language Specification v1.2, dated 2003
Where can I find descriptions of how they differ?
> And as I recall, C\C++ reserved all names starting with __ or something to that effect, so it was your fault if you screwed up, they told you beforehand what not to use.
C++ added the keyword "mutable" (and others). There are no leading
underscores. I shit on breaking changes. The code is quickly corrected and
thats better than having to write ___mutable the next 30 years I use this
language!
--
cody
[Freeware, Games and Humor] www.deutronium.de.vu || www.deutronium.tk
"Eric Gunnerson [MS]" <er****@online. microsoft.com> wrote in message news:<Oc******* *******@tk2msft ngp13.phx.gbl>. .. -- Eric Gunnerson
Visit the C# product team at http://www.csharp.net Eric's blog is at http://blogs.gotdotnet.com/ericgu/
This posting is provided "AS IS" with no warranties, and confers no rights. "cody" <do************ *********@gmx.d e> wrote in message news:bn******** *****@ID-176797.news.uni-berlin.de... Partials are just stupid
I have a bad feeling about them too but look into reality programming.
Often Forms-classes can get really huge and now imagine you are working in a team and more than 1 programmer wants to work on that class. Additionally automatically generated code can be separated from written code. Maybe they aren't as bad when you once get used to them-
The big goal for partial classes *is* for generated code. Being able to keep that separate from the user code simpifies the user model.
Code generation is a work-around for bad languages and/or libraries.
If the language has sufficient power and libraries are well-designed
then there is little need to generate code. For example, you could
use Lex and YACC to generate C++ code, or you could use the SPIRIT
parser classes instead.
>That sounds like a really bad reason to use partial types, IMO. Is it really not possible to refactor that code into more classes which would increase the readability of the code to start with? I've only *very* rarely seen classes which really deserve to be that long.
I am not saying that there way of doing things is right or wrong. I can
definitely say I have written my share of crap code durin my 16 years a a
programmer, but I did hear someone say one time that if a class printout does
not fit on just one page, it is probably too long. :)
"cody" <do************ *********@gmx.d e> wrote in message
news:bn******** *****@ID-176797.news.uni-berlin.de... And as I recall, C\C++ reserved all names starting with __ or something
to that effect, so it was your fault if you screwed up, they told you beforehand what not to use. C++ added the keyword "mutable" (and others). There are no leading underscores. I shit on breaking changes. The code is quickly corrected and thats better than having to write ___mutable the next 30 years I use this language!
Well, when it comes down to it, thats your problem. You are really far to
rude to actually achieve anything. But, anyway, adding a keyword when it has
to be added is one thing, in this case its not, no matter how much you want
to complain about it. -- cody
[Freeware, Games and Humor] www.deutronium.de.vu || www.deutronium.tk
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Andrew James |
last post by:
Gentlemen,
I'm currently in the process of designing a language which will be used
to specify sets of files on a WebDAV server, encoded in a URL. The aims
of the language are to (in no particular order):
* Be concise, aesthetic and easy to type
* Be as similar as possible to existing query languages
* Allow for (nested) boolean operations
* Be cross-platform (so don't include any characters which can't be
used in filenames on *NIX or...
|
by: Erwin Moller |
last post by:
Hi group,
I am a bit cconfused with the different tags I encounter to start a script.
I used to use: language="Javascript"
Nowadays I use: type="text/javascript"
I did see some javascript1.2 (i think) too, but never used that.
But when I let my favorite editor (Eclipse) do some codecompletion I get:
|
by: Vincent |
last post by:
I would like to develop a site that should be available in several
languages, say English, French and German. My question is: how can I
suggest browsers of visitors to display the correct language depending
on their preferences ?
Let me explain this more clearly: in many browsers, you are given the
possibility to choose your preferred language: fr, en, de, etc.
Typically, in Mozilla, this option is detailed as follows:
"Web pages are...
|
by: Tristan Miller |
last post by:
Greetings.
Do any popular browsers correctly support <q>, at least for Western
languages? I've noticed that Mozilla uses the standard English
double-quote character, ", regardless of the lang attribute of the HTML
document. Will any browsers render German-style quotes or French-style
guillemots for lang="de" and lang="fr", respectively?
Regards,
Tristan
|
by: Thomas G. Marshall |
last post by:
Arthur J. O'Dwyer <ajo@nospam.andrew.cmu.edu> coughed up the following:
> On Thu, 1 Jul 2004, Thomas G. Marshall wrote:
>>
>> Aside: I've looked repeatedly in google and for some reason cannot
>> find what is considered to be the latest ansi/iso C spec. I cannot
>> even find C99 in its final draft. Where in ansi.org or the like do
>> I find it?
>
> The official C99 specification is copyright ISO and distributed by
> various national...
| |
by: Randy Yates |
last post by:
In Harbison and Steele's text (fourth edition, p.111)
it is stated,
The C language does not specify the range of integers that the
integral types will represent, except ot say that type int may not
be smaller than short and long may not be smaller than int.
They go on to say,
Many implementations represent characters in 8 bits, type short in
|
by: evolnet.regular |
last post by:
I've been utilising C for lots of small and a few medium-sized personal
projects over the course of the past decade, and I've realised lately
just how little progress it's made since then. I've increasingly been
using scripting languages (especially Python and Bourne shell) which
offer the same speed and yet are far more simple and safe to use. I can
no longer understand why anyone would willingly use C to program
anything but the lowest...
|
by: Marshal [DirectX MVP 2003] |
last post by:
In anticipation of the chat, I have filtered all of my current enhancement
aleration ideas through the software development community, via the following
postings:
C# Language Specification - Delegates
C# Language Specification - Extension Methods
C# Language Specification - Enumeration
C# Language Specification - Generics
If anybody else has posted enhancement or alteration proposals in
|
by: Xah Lee |
last post by:
The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully
Functional Notations
Xah Lee, 2006-03-15
Let me summarize: The LISP notation, is a functional notation, and is
not a so-called pre-fix notation or algebraic notation.
Algebraic notations have the concept of operators, meaning, symbols
placed around arguments. In algebraic in-fix notation, different
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |