Is this spaghetti?
-
I am working on an existing C# application, and find that there is a set of class definitions like this:
public class Class1 { }
public abstract class Class2 { }
public class Concrete2 : Class2 { }
public class Report { }
public class Class3 : Concrete2
{
public Class1 report = new ();
}Would you call this spaghetti code? Or, is this a standard Design Pattern? Currently, it is causing my mind to whirl.
-
I am working on an existing C# application, and find that there is a set of class definitions like this:
public class Class1 { }
public abstract class Class2 { }
public class Concrete2 : Class2 { }
public class Report { }
public class Class3 : Concrete2
{
public Class1 report = new ();
}Would you call this spaghetti code? Or, is this a standard Design Pattern? Currently, it is causing my mind to whirl.
-
I am working on an existing C# application, and find that there is a set of class definitions like this:
public class Class1 { }
public abstract class Class2 { }
public class Concrete2 : Class2 { }
public class Report { }
public class Class3 : Concrete2
{
public Class1 report = new ();
}Would you call this spaghetti code? Or, is this a standard Design Pattern? Currently, it is causing my mind to whirl.
Namaskara, I'd call it "sloppy pasta" without mnemonic flavors of some strange twisty type, but, definitely not idiyappam :) imho, the best way to evaluate/study it is to ... if you are convinced it is safe, and, it does something interesting ... set break-points and single-step through some code that instantiates the classes. cheers, Bill
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch
-
Namaskara, I'd call it "sloppy pasta" without mnemonic flavors of some strange twisty type, but, definitely not idiyappam :) imho, the best way to evaluate/study it is to ... if you are convinced it is safe, and, it does something interesting ... set break-points and single-step through some code that instantiates the classes. cheers, Bill
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch
Namaskara, That's what I am doing, putting breakpoints, and going through it step by step. Thanks
-
Thanks. Will go through this Abstract Factory pattern.
-
I am working on an existing C# application, and find that there is a set of class definitions like this:
public class Class1 { }
public abstract class Class2 { }
public class Concrete2 : Class2 { }
public class Report { }
public class Class3 : Concrete2
{
public Class1 report = new ();
}Would you call this spaghetti code? Or, is this a standard Design Pattern? Currently, it is causing my mind to whirl.
this just look like a bunch of class in the same file. there is hardly enough to call that anything... :) for example
public class List {}
public abstract Visual {}
public class UIElement : Visual {}public class String {}
public class FrameworkElement : UIElement
{
public List strings = new ();
}Unless you mean to suggest? perhaps split that in a few files? that not spaghetti, but that would be a little more organisation! :) spaghetti code is about code lacking.... hierarchical stucture, well defined responsibility, that sort of thing. Not so much about whether the code is one humongous file or many small ones.
A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!
-
this just look like a bunch of class in the same file. there is hardly enough to call that anything... :) for example
public class List {}
public abstract Visual {}
public class UIElement : Visual {}public class String {}
public class FrameworkElement : UIElement
{
public List strings = new ();
}Unless you mean to suggest? perhaps split that in a few files? that not spaghetti, but that would be a little more organisation! :) spaghetti code is about code lacking.... hierarchical stucture, well defined responsibility, that sort of thing. Not so much about whether the code is one humongous file or many small ones.
A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!
This makes sense. I am starting to understand the code.
-
Namaskara, I'd call it "sloppy pasta" without mnemonic flavors of some strange twisty type, but, definitely not idiyappam :) imho, the best way to evaluate/study it is to ... if you are convinced it is safe, and, it does something interesting ... set break-points and single-step through some code that instantiates the classes. cheers, Bill
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch
The sauce however lacks body and flavour. :-D
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
-
I am working on an existing C# application, and find that there is a set of class definitions like this:
public class Class1 { }
public abstract class Class2 { }
public class Concrete2 : Class2 { }
public class Report { }
public class Class3 : Concrete2
{
public Class1 report = new ();
}Would you call this spaghetti code? Or, is this a standard Design Pattern? Currently, it is causing my mind to whirl.
It would depend on what the classes contained: it's quite possible for that to be a good design - and the Concrete2 class could be just trying to get round a bug in teh VS designer that has been unfixed since the first release of .NET: you can't use the designer on a Control derived from an abstract class without a dummy concrete class between them:
public abstract class MyBase: UserControl { ... }
public class _MyBase: MyBase {}
public class MyControl : _MyBase { ... }The designer can open
MyBase
andMyControl
, but can't open_MyBase
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
-
It would depend on what the classes contained: it's quite possible for that to be a good design - and the Concrete2 class could be just trying to get round a bug in teh VS designer that has been unfixed since the first release of .NET: you can't use the designer on a Control derived from an abstract class without a dummy concrete class between them:
public abstract class MyBase: UserControl { ... }
public class _MyBase: MyBase {}
public class MyControl : _MyBase { ... }The designer can open
MyBase
andMyControl
, but can't open_MyBase
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
Thanks for your reply. I am starting to understand the code, and it seems to be too intelligent a design for a lay person like me.
-
I am working on an existing C# application, and find that there is a set of class definitions like this:
public class Class1 { }
public abstract class Class2 { }
public class Concrete2 : Class2 { }
public class Report { }
public class Class3 : Concrete2
{
public Class1 report = new ();
}Would you call this spaghetti code? Or, is this a standard Design Pattern? Currently, it is causing my mind to whirl.
-
I am working on an existing C# application, and find that there is a set of class definitions like this:
public class Class1 { }
public abstract class Class2 { }
public class Concrete2 : Class2 { }
public class Report { }
public class Class3 : Concrete2
{
public Class1 report = new ();
}Would you call this spaghetti code? Or, is this a standard Design Pattern? Currently, it is causing my mind to whirl.
-
Greetings Kind Regards May I please inquire as to why your name is red colored Thank You - Cheerio
-
Greetings Kind Regards May I please inquire as to why your name is red colored Thank You - Cheerio
-
Hmmm, Let's make a deal. If you tell me why you don't use any punctuation in your writings then I will tell you why my name is
Red
. Deal?Okee-Dokee I know a fellow much smarter than myself He suggested it He annoys me greatly if I don't take his advice This one I more or less am inclined to as he convinced me that punctuation marks seem as maculation on the page though I have a certain fondness for a well placed comma but periods I can live without His stated argument was when people speak they do not speak "comma" or "period" as would otherwise be placed in text Of course pauses and intonation do the job as he well knows but so far so good more or less Though I may return to my previous usual usage of ,'s, .'s and ?'s etc. - Cheerio
-
I am working on an existing C# application, and find that there is a set of class definitions like this:
public class Class1 { }
public abstract class Class2 { }
public class Concrete2 : Class2 { }
public class Report { }
public class Class3 : Concrete2
{
public Class1 report = new ();
}Would you call this spaghetti code? Or, is this a standard Design Pattern? Currently, it is causing my mind to whirl.
No. Spaghetti tastes good.
Nothing succeeds like a budgie without teeth.
-
I am working on an existing C# application, and find that there is a set of class definitions like this:
public class Class1 { }
public abstract class Class2 { }
public class Concrete2 : Class2 { }
public class Report { }
public class Class3 : Concrete2
{
public Class1 report = new ();
}Would you call this spaghetti code? Or, is this a standard Design Pattern? Currently, it is causing my mind to whirl.
I don't know what this is, but it's not spaghetti code. Spaghetti code is when you break the sequential flow of your code by jumping to somewhere else, without the possibility to come back. One would think it is not used anymore these days, but that is not really true. Every time you write a return in the middle of a method you actually break the sequential flow, which is technically speaking spaghetti code. Granted this has not the disastrous consequences as the old goto, but still...
-
I am working on an existing C# application, and find that there is a set of class definitions like this:
public class Class1 { }
public abstract class Class2 { }
public class Concrete2 : Class2 { }
public class Report { }
public class Class3 : Concrete2
{
public Class1 report = new ();
}Would you call this spaghetti code? Or, is this a standard Design Pattern? Currently, it is causing my mind to whirl.
No comments in the code?
Paul Sanders http://www.alpinesoft.co.uk
-
Okee-Dokee I know a fellow much smarter than myself He suggested it He annoys me greatly if I don't take his advice This one I more or less am inclined to as he convinced me that punctuation marks seem as maculation on the page though I have a certain fondness for a well placed comma but periods I can live without His stated argument was when people speak they do not speak "comma" or "period" as would otherwise be placed in text Of course pauses and intonation do the job as he well knows but so far so good more or less Though I may return to my previous usual usage of ,'s, .'s and ?'s etc. - Cheerio
What makes you think this fellow is much smarter than yourself?
-
Okee-Dokee I know a fellow much smarter than myself He suggested it He annoys me greatly if I don't take his advice This one I more or less am inclined to as he convinced me that punctuation marks seem as maculation on the page though I have a certain fondness for a well placed comma but periods I can live without His stated argument was when people speak they do not speak "comma" or "period" as would otherwise be placed in text Of course pauses and intonation do the job as he well knows but so far so good more or less Though I may return to my previous usual usage of ,'s, .'s and ?'s etc. - Cheerio
PaltryProgrammer wrote:
when people speak they do not speak "comma" or "period" as would otherwise be placed in text
It just occurred to me that you may have a disability that requires speech-to-text. I apologize for asking, I should have thought about this. I've been here on codeproject for nearly 20 years. Many years ago Chris added support for colorized usernames, around 15 years ago the forums were full of users with colored names, it seems I am one of the last users left that use this feature. The color has no meaning. Best Wishes, -David Delaune