Ranjan Sakalley

Sponsors

The Lounge

News

  • CodeBetter.Com Home



    I'm test-driven!



Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
On partial types in C# 2.0, and other redundancies

For some time, I have been thinking about language contructs that are a pain when it comes to code management, readability and more often than not inculcate poor coding habits amongst developers.

  • Nested classes -I have never found a valid reason to use them. I really feel that an inner class is something that looks better in books and asked in interviews. I haven't noticed a single instance where you *really* need a nested class. I am sure there are better, much more readable ways to code.
  • params - One can easily go with a collection/DTO which holds the required parameters. It is a just redundant. If I do not have the exact number of parameters that a function I write expects, I would use an array, like its done in a BeginInvoke call for a Control instance
    public virtual IAsyncResult BeginInvoke(
       Delegate method,
       
    object[] args)

     Morover, If I ever use more than 10 input ( + output ) parameters, and not think about a DTO, I would better stop programming and start afresh on alchemy (not a bad idea either).

There is goto but I will never let go of it, reminds me of better times ( jmp is still there at the top, and will remain), even though I prefer not to use it.  

   Now with 2.0 comes another new one. partial classes. The documentation more than tries to please the reader and clearly indicates that this is really needed for Code generation, Windows forms underlined. There is a problem here, not only is it *not needed*, it is powerful enough for a set of developers to develop a bad habit, rather than code. Ofcourse there are better ways to hide generated code, XAML +/ inheritance (as with ASP.Net web-pages) for designs atleast, or arent't they?

Two developers maintaining a class is a maintainance problem, three is a disaster. And partial interfaces ?

 


Posted 02-01-2005 12:57 AM by rsakalley
Filed under:

[Advertisement]

Comments

kpako@yahoo.com (Dare Obasanjo) wrote RE: On partial types in C# 2.0, and other redundancies
on 01-31-2005 9:55 PM
So instead of writing System.WriteLine("My name is {0} {1}", firstname, lastname) you think writing System.WriteLine("My name is {0} {1}", new object[]{firstname, lastname}) is better?

Yeah, right.
Ranjan wrote re: On partial types in C# 2.0, and other redundancies
on 01-31-2005 10:37 PM
Dare,
String.Format etc. have the right implementations. What I was talking about is that such constructs more or less inculcate bad habits.


Frans Bouma wrote re: On partial types in C# 2.0, and other redundancies
on 02-01-2005 12:22 AM
Partial classes are a great thing to have: you can place the code generated by a code generator in another file, it effectively disconnects a class from the file paradigm which is great.

If some team goes bezerk over this feature, I think it's more a problem related to management than to the developer. I mean: what's so hard to understand about:
- one part is for code generation
- one part is for extension through custom code.
Ranjan wrote re: On partial types in C# 2.0, and other redundancies
on 02-01-2005 12:32 AM
Frans,
First of all, thanks for visiting my space :)
Definitely agree with you on the dependency on the file part, but I still feel that like the ASPX/code behind scene, an XAML/code scene could be modelled. Also, yes it is easy for us to understand that one file is for code gen, another for custom code, but thats where it should end, and not become a generic feature in the language, until there is a reason which I am not able to see <rant self/>
Wesner Moise wrote re: On partial types in C# 2.0, and other redundancies
on 02-01-2005 2:12 AM
I believe that all the features that you declare redundant are all valuable.

Nested classes have the unique advantages over other types of classes in that they have access to private members of outer classes and that they reduce namespace.

Partial classes only monolithic files to be broken up by functions for maintenability, they support code generation in a much more elegant manner. Use of inheritance is not a substitute; there are certain types of methods that can't be inherited... In addition, structs can't be inherited.

Ranjan wrote re: On partial types in C# 2.0, and other redundancies
on 02-01-2005 2:31 AM
Wesner,
I still believe nested classes are a poor design decision.And regarding structs and inheritance, I dont see any reason why anybody would write a struct spanning more than a hundred lines, and maintain it across 2 files?
Thanks
Ranjan
Ani Ideal Boy wrote re: On partial types in C# 2.0, and other redundancies
on 02-13-2005 6:40 PM
internal classes....
maybe you will never use them when you are solving a problem on your own

but what about Java to C# or
C++ to C#

There maybe cases where you need that redundant feature just for making things work. Because as you said sometime back, they may not give you a chance to redesign and want you to simply port it. I know of a place where this is happening and thats why I simply opted out of it :)
Confusticated wrote re: On partial types in C# 2.0, and other redundancies
on 02-15-2005 2:47 AM
I don't want to call you crazy for your personal style preferences, but I disagree that these features are either redundant or encourage bad habits.

You rail on three pieces I think add a lot of flexibility and actually improve readability and maintenance.

Nested classes: Although you don't see it too often these days, private internal classes can be very handy, especially in utility classes. Not exposing these helpers (whether or not they need access to the parent's members) helps keep the object model cleaner.

params keyword: This is one of the features I really love. Granted, in C#, it's easy enough to pass a new object[] {one, two, three}, but the cleanliness is unsurpassed. The only language I can think of that actually provides a more flexible calling convention is Python.

Partial types: The code-gen/manual edit model is the obvious winner for this technique. Another winner is someone who doesn't have a fancy IDE available all of the time for folding large sections down. The ability to break out finalized/testing/exception handling/ugly code into other files is also a strong benefit. I doubt many people will be experimenting with "I wonder if it's good to have one method per file." It's all about breaking the job into pieces as large as are sensible and digestable.

All of that said, I feel your pain. There are a lot of "features" in a lot of packages/languages that bother me on a style level. It's just that, in this case, all of these features are completely optional and have no impact on a developer who doesn't like the flavor.

Ranjan wrote re: On partial types in C# 2.0, and other redundancies
on 02-15-2005 3:00 AM
Already apologized for the partial type messup. But apart from that, the other 2 are just tweaks and I still stand behind my "style preferences".
Stoyan wrote re: On partial types in C# 2.0, and other redundancies
on 02-15-2005 5:02 AM
Re nested classes - I've never seen a cleaner way to create a enumerator for a custom collection of mine, e.g.

class MyCollection : IEnumerable
{
[...]
public IEnumerator GetEnumerator()
{
return new Enumerator(this);
}
[...]
private class Enumerator : IEnumerator
{
public Enumerator(MyCollection parent)
{
[...]
}
}
}

Cheers,
Stoyan
Ranjan wrote re: On partial types in C# 2.0, and other redundancies
on 02-15-2005 4:25 PM
Coolest use ever. But i still prefer the normal way :(. Sorry. But I really appreciate the comment, learnt something new today
NeVaL wrote re: On partial types in C# 2.0, and other redundancies
on 12-28-2006 6:08 AM

http://www.leffat-imuroitavat.beibi.info ^^^ http://www.leffat-ring2.beibi.info ^^^ http://www.kari-naken-porno.biseksuell.info ^^^ http://www.harete-handjager-bilde.biseksuell.info ^^^ http://www.kari-naken-porno.erotiska.info ^^^ http://www.harete-handjager-bilde.erotiska.info ^^^ http://www.mpeg-jungfru-sexig.fitta69.info ^^^ http://www.kryp-moder-gif.fitta69.info ^^^ http://www.klipp-naturlig-handtralla.fotsex.info ^^^ http://www.foto-penis-sexig.fotsex.info ^^^ http://www.pirkan-pakkaus.isomuna.info ^^^ http://www.talossa-viaton.isomuna.info ^^^ http://www.alamaissa-oleva-lollo.laukeaminen.info ^^^ http://www.marleena-peraaukon-huora.laukeaminen.info ^^^ http://www.portretter-exstreme-naturals.rype.info ^^^ http://www.exstrem-foto-filmrull.rype.info ^^^ http://www.bilder-rav-harete.sadsprut.info ^^^ http://www.gratis-fitte-sexy.sadsprut.info ^^^ http://www.leike-keittiossa-ulkona.tytsy.info ^^^ http://www.mpegit-sexbra.tytsy.info ^^^ http://www.anal-lesbians-gallery.18analsex.com ^^^ http://www.pics-photos-ass.18analsex.com ^^^ http://www.titolo-tesina-adolescenza.pazzesesso.com ^^^ http://www.mpg-hot-clits.pazzesesso.com ^^^ http://www.angela-cavagna-avi.figanere.com ^^^ http://www.nudisti-naturisti-fotografia.figanere.com ^^^ http://www.avi-culetto-bagnati.inculatexxx.com ^^^ http://www.calendario-sexy-modella-2007.inculatexxx.com ^^^ http://www.shakira-pecorina-filmato.prostitutaculo.com ^^^ http://www.mpg-iomilu-old.prostitutaculo.com ^^^ http://www.filmato-bionda-affamate.lesbicastrip.com ^^^ http://www.belinda-bauer.lesbicastrip.com ^^^ http://www.mails-cachondos.007sexogratis.com ^^^ http://www.lesbianas-asiatica-clip.007sexogratis.com ^^^ http://www.videos-insestos-avi.3sexogratis.com ^^^ http://www.movieclip-foto-nudistas.3sexogratis.com ^^^ http://www.terapia-alternativa.analsexogratis.com ^^^ http://www.foto-wicked-bikini.analsexogratis.com ^^^ http://www.venezolanas-catalog.cam-sexo-gratis.com ^^^ http://www.avi-nenita-ardiente.cam-sexo-gratis.com ^^^

Smułko wrote re: On partial types in C# 2.0, and other redundancies
on 01-24-2007 3:35 AM

http://percepire-bionde-strip.wuagpgr8vhh.info/

http://piccola-cecoslovacche.nupsvtr1xzi.info/

http://fair-amatoriali-dildo.nvovay9vegv.info/

http://il-nostro.3wcekxwg3md.info/

http://433v2ml.u3yomyk50cp.info/

http://fresco-sposa.jht3k7963m7.info/

http://novita-telefoni-cellulare.hgmtpx1eyo1.info/

http://intermedio-latina.cn3u6te3gqn.info/

http://www.101qprrep2h.info/al-13-maggio-respond.html

http://foto-ubriache.crlawhxqgwi.info/

http://bbw-homepage.u4re8o6n1qf.info/

http://freddissimo-comprensivo-nubile.3wcekxwg3md.info/

http://celestiale-modesto.101qprrep2h.info/

http://www.osip2hukpfy.info/usb-siemens-sl65.html

http://piccola-tv.1xl80kcb2o6.info/

http://www.2qhtadoaxcg.info/retiring-bionde-fottilo.html

http://sentimentale-lesbiche-azione.o8nr6j39nzr.info/

http://uqd3ehco.u3yomyk50cp.info/

http://149032248.zp9as3i9llc.info/

http://accommodation-italy.wuagpgr8vhh.info/

http://voli-offerta-sicilia.hgmtpx1eyo1.info/

http://in-pace-more.u4re8o6n1qf.info/ http://www.azvu.nom.es/belle-tettone.html

http://www.quad.org.es/agriturismo-toscana-italia.html

http://8ybprvj.arteg.nom.es/

http://www.bomet.nom.es/149949264/

http://145251008.luce.nom.es/

http://laughable-cowgirl-anale-fotti.vidot.com.es/

http://145186528.luce.nom.es/

http://145213564.luce.nom.es/

http://www.sbmr.org.es/hotel-economico-ginevra.html

http://144674756.cabtf.nom.es/

http://pattern-toscana.dfms.org.es/

http://www.vidot.com.es/fnywh1xp/

http://www.dindl.nom.es/cuttiest-fighette-doppio-penetrazione.html

http://www.pipes.org.es/codardo-amatoriali-gruppo.html

http://t5mvgelajbm.cemaf.org.es/

http://foto-solo-ermafrodita.cranv.com.es/

http://www.i-s-t.nom.es/sentimentale-bionde-strip.html

http://ccyjkxa3kr.sbmr.org.es/

http://kfv4faqlin.cemaf.org.es/

http://www.kinds.nom.es/mutuo-fondiari-finanziamento.html

http://www.azvu.nom.es/pacchetto-vacanza-corfu.html

http://www.bisg.org.es/coy-cowgirl-merda.html

http://www.quad.org.es/sciarpa-parma.html

http://144944644.bibbo.com.es/

http://cuttiest-fighetta-masturbate.vidot.com.es/

http://www.bolid.nom.es/funny-cameriera-azione.html

http://www.cabtf.nom.es/taglio-agente-di-polizia-spogliarello.html

http://93ptc28.subli.org.es/

lublu wrote re: On partial types in C# 2.0, and other redundancies
on 01-25-2007 10:45 AM

http://www.yoora.lublu.nom.es/amabile-media.html

http://www.beepoo.lublu.nom.es/allievo-figa-fotti-a-letto.html

http://www.dobloo.lublu.nom.es/144967412/

http://www.sesssssso.lublu.nom.es/stupefacente-infermiera-doppio-penetrazione.html

http://www.beepoo.lublu.nom.es/uomo-sex.html

http://www.vigorex.lublu.nom.es/145924896.html

http://www.beepoo.lublu.nom.es/likeable-giovane-ubriache.html

http://www.5veretroie.lublu.nom.es/multinazionale-brescia.html

http://www.5veretroie.lublu.nom.es/esibizioniste-sex.html

http://www.yoora.lublu.nom.es/incontro-roma.html

http://www.20070124.lublu.nom.es/telefonino-it.html

http://www.vigorex.lublu.nom.es/145925316.html

http://www.virtualepp.lublu.nom.es/alloggio-calabria.html

http://www.vigorex.lublu.nom.es/145925928.html

http://www.beepoo.lublu.nom.es/voyeur-tiziana.html

http://www.virtualepp.lublu.nom.es/diabolica-roma.html

http://www.20070124.lublu.nom.es/intrepido-infermiera-inculate.html

http://www.aldona.lublu.nom.es/sardegna-hotel.html

http://www.vicek23.lublu.nom.es/soggetti-maglietta/

http://www.5veretroie.lublu.nom.es/handsome-segretaria-gruppo.html

http://www.dobloo.lublu.nom.es/144797456/

http://www.ititit.lublu.nom.es/italia-incontri-donna.html

http://www.virtualepp.lublu.nom.es/gainers.html

http://www.virtualepp.lublu.nom.es/assurdo-lesbiche.html

http://www.yoora.lublu.nom.es/beauty-fighette-spogliarello.html

http://www.5veretroie.lublu.nom.es/fellazione-www.html

http://www.vicek23.lublu.nom.es/conifere-puglia/

http://www.dobloo.lublu.nom.es/144968912/

http://www.yoora.lublu.nom.es/sborrate-in-culo.html

http://www.sexy1video.lublu.nom.es/3mx3j9f.html

http://www.idib-c.lublu.nom.es/piscina-salo.html

http://www.ititit.lublu.nom.es/inculate-negre.html

http://www.vicek23.lublu.nom.es/sistema-com/

volf wrote re: On partial types in C# 2.0, and other redundancies
on 02-13-2007 5:13 AM

http://www.bmjet.nom.es/pictures/nztah9zhi/ :i:

http://www.bmjet.nom.es/x_files04/opu5249vv.html :i:

http://www.bmjet.nom.es/boards/next0008/144845464/ :i:

http://www.bmjet.nom.es/blogs/e6m52b5s4/ :i:

http://www.bmjet.nom.es/blogs/past0004/qfee9g3c/ :i:

http://www.bmjet.nom.es/x_files09/zczxd7f6q4f.html :i:

http://www.bmjet.nom.es/x_files03/oe3437sjrn.html :i:

http://www.bmjet.nom.es/x_files09/oog2r6x4h.html :i:

http://www.bmjet.nom.es/x_files01/gl7he19lfb.html :i:

http://www.bmjet.nom.es/x_files06/ab3i6ve.html :i:

http://www.bmjet.nom.es/boards/archives/145326996/ :i:

http://www.bmjet.nom.es/boards/next0005/144380152/ :i:

http://www.bmjet.nom.es/blogs/htvyjap/ :i:

http://www.bmjet.nom.es/boards/next0004/145029620/ :i:

http://www.bmjet.nom.es/boards/next0005/144462308/ :i:

http://www.bmjet.nom.es/boards/archives/145326576/ :i:

http://www.bmjet.nom.es/x_files01/wc3wy7eyeb3.html :i:

http://www.bmjet.nom.es/x_files09/gmylpob25.html :i:

http://www.bmjet.nom.es/boards/next0010/145790100/ :i:

http://www.bmjet.nom.es/boards/next0010/145836360/ :i:

http://www.bmjet.nom.es/blogs/past0005/xge3gxhtnuf/ :i:

http://www.bmjet.nom.es/x_files09/urgo4dj.html :i:

http://www.bmjet.nom.es/blogs/past0002/1qu4p3l/ :i:

http://www.bmjet.nom.es/x_files02/fei33at.html :i:

http://www.bmjet.nom.es/blogs/past0005/gyrayjuc8g/ :i:

http://www.bmjet.nom.es/x_files07/dwkp6ih933.html :i:

http://www.bmjet.nom.es/x_files10/clo3eg8ro.html :i:

http://www.bmjet.nom.es/blogs/ruedgttxxl/ :i:

http://www.bmjet.nom.es/x_files06/pmclj5v.html :i:

http://www.bmjet.nom.es/blogs/past0004/oj3gd4ppy3q/ :i:

http://www.bmjet.nom.es/boards/u0004/jmtoqocy8ej.html :i:

http://www.bmjet.nom.es/boards/u0002/u7r4kf8tmh.html :i:

http://www.bmjet.nom.es/blogs/past0005/jpb6ndx/ :i:

volf wrote re: On partial types in C# 2.0, and other redundancies
on 02-13-2007 5:13 AM

http://www.aviv.nom.es/extra_member/8lrn9yzaqob.html [#]

http://www.aviv.nom.es/next/003/adqqljtcss1/ [#]

http://www.users.aviv.nom.es/pages/bello-fighetta-inculate.html [#]

http://www.members.aviv.nom.es/0_06/online-marketing-degree.html [#]

http://www.aviv.nom.es/next/007/144798288.html [#]

http://nonsensical-asiatiche-doppio-penetrazione.aviv.nom.es/ [#]

http://www.aviv.nom.es/next/008/prestito-fabbrico.html [#]

http://www.aviv.nom.es/next/010/jccotc2.html [#]

http://www.users.aviv.nom.es/41l414v.html [#]

http://www.octo.aviv.nom.es/uqz79ex/ [#]

http://www.members.aviv.nom.es/0_02/lesbiche-che-fanno-l-amore-sotto-la-doccia.html [#]

http://www.aviv.nom.es/free/14kh4gg/ [#]

http://www.members.aviv.nom.es/0_10/ifwlpae.html [#]

http://www.members.aviv.nom.es/0_02/tgp-calze-sporche.html [#]

http://www.members.aviv.nom.es/0_01/inchiodare-cowgirl-amore.html [#]

http://www.members.aviv.nom.es/0_04/video-erotici-gratis-della-bambola-ramona.html [#]

http://www.aviv.nom.es/next/005/145128980.html [#]

http://www.members.aviv.nom.es/0_02/piacente-esotiche.html [#]

http://www.aviv.nom.es/next/008/t4ckeb8/ [#]

http://affetto-cowgirl-figa-fotti.aviv.nom.es/ [#]

http://www.members.aviv.nom.es/0_03/sport-puma.html [#]

http://www.users.aviv.nom.es/pages/145675820/ [#]

http://www.aviv.nom.es/xxx/xe8lsfburz.html [#]

http://www.aviv.nom.es/sites/looq7a1.html [#]

http://insensato-fighetta-urinate.aviv.nom.es/ [#]

http://www.members.aviv.nom.es/0_10/sexli/ [#]

http://www.aviv.nom.es/next/005/145112008/ [#]

http://www.members.aviv.nom.es/0_03/router-wireless-scheda.html [#]

http://www.aviv.nom.es/next/008/videogioco-game-cube.html [#]

http://www.aviv.nom.es/next/007/144737668.html [#]

http://www.users.aviv.nom.es/pages/145680736/ [#]

http://divino-agente-di-polizia.aviv.nom.es/ [#]

http://www.members.aviv.nom.es/0_05/enema.html [#]

http://www.users.aviv.nom.es/cop53x4citp.html [#]

kop wrote re: On partial types in C# 2.0, and other redundancies
on 02-19-2007 4:48 PM

Add a Comment

(required)  
(optional)
(required)  
Remember Me?