Tag Info

New answers tagged

3

I believe that you should either expose object TextBlock from Page or have delegate methods in Page to provide access to the methods of TextBlock but not both. I guess it depends how many properties and methods of TextBlock you want to expose, so if they are many, that just provide TextBlock and do not have all those simple delegations. You can also check ...


2

Making "wrapper properties" like this is fine if it's the cleanest way to implement the API that you want this class to have. However, the specific example you posted does look questionable to me, mostly because the user of your class can now do exactly the same thing in two different ways: myPage.MainParagraph.Text and myPage.MainText. Since the user ...


1

Sometimes (rarely), it seems that creating a function that takes a decent amount of parameters is the best route. Using several parameters is often a clear indicator, that you violate the SRP in this method. A method, which needs many parameters is unlikely to do only one thing. Excpetion may be a mathematical function or a configuration method, where ...


0

The technique I use is to combine, and outsource the validation and throwing altogether to a utility function. The single most important benefit is that it is reduced down to a one-liner in the business logic. I bet you can't do better unless you can reduce it further - to eliminate all argument validations and object-state guards from the business logic, ...


1

For the public SDK scenario, I would strongly consider using Microsoft Code Contracts as these provide informative errors, static checks and you can also generate documentation to add into XML docs and Sandcastle generated help files. It is supported in all paid for versions of Visual Studio. An additional advantage is that if your customers are using C#, ...


0

IMHO there is only one case where using partial classes makes sense. But in that case it does make a lot of sense. And that case is when you are using a tool to automatically generate code, e.g. based on a database schema, XSD schema files, or something else, and you need to add functions to the auto-generated code classes. In that case, partial classes ...


0

One danger not yet mentioned with partial classes is that there is no way--short of adding an extra level of inheritance--of indicating that all object construction must be done through a particular constructor. Given: class Fnorble { protected readonly int[] biz,boz; public Fnorble(int size) { biz = new int[size]; boz = new int[size]; } } ...



Top 50 recent answers are included