How do I alias a class name in C#, without having to add a line of code to every file that uses the class?

You can’t. The next best thing you can do is have using declarations in the files that use the class. For example, you could rewrite the dependent code using an import alias (as a quasi-typedef substitute): using ColorScheme = The.Fully.Qualified.Namespace.Outlook2007ColorScheme; Unfortunately this needs to go into every scope/file that uses the name. I therefore don’t … Read more

Is UML practical? [closed]

Using UML is like looking at your feet as you walk. It’s making conscious and explicit something that you can usually do unconsciously. Beginners need to think carefully about what they’re doing, but a professional programmer already knows what they’re doing. Most of the time, writing the code itself is quicker and more effective than … Read more

Why is __init__() always called after __new__() in Python?

Use __new__ when you need to control the creation of a new instance. Use __init__ when you need to control initialization of a new instance. __new__ is the first step of instance creation. It’s called first, and is responsible for returning a new instance of your class. In contrast, __init__ doesn’t return anything; it’s only … Read more

How do I design a class in Python?

How to design a class. Write down the words. You started to do this. Some people don’t and wonder why they have problems. Expand your set of words into simple statements about what these objects will be doing. That is to say, write down the various calculations you’ll be doing on these things. Your short … Read more

How will I know when to create an interface?

it solves this concrete problem: you have a, b, c, d of 4 different types. all over your code you have something like: a.Process(); b.Process(); c.Process(); d.Process(); why not have them implement IProcessable, and then do List<IProcessable> list; foreach(IProcessable p in list) p.Process(); this will scale much better when you add, say, 50 types of … Read more

How do you design object oriented projects? [closed]

The steps that I use for initial design (getting to a class diagram), are: Requirements gathering. Talk to the client and factor out the use cases to define what functionality the software should have. Compose a narrative of the individual use cases. Go through the narrative and highlight nouns (person, place, thing), as candidate classes … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)