Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.
73

I'll expand my comment: ... if you're adding or removing elements, you want a list (or other flexible data structure). Arrays are only really good when you know exactly how many elements you need at the start. A Quick Breakdown Arrays are good when you have a fixed number of elements that is unlikely to change, and you wish to access it in a non-...


25

MVVM(Model-View-ViewModel) Pattern can be used in the Winforms Model public class Person { public string FirstName {get; set;} public string LastName {get; set;} } ViewModel public class PersonViewModel : INotifyPropertyChanged { private Person _Model; public string FirstName { get { return _Model.FirstName; } set(...


24

It looks like you've fallen into some of the common pitfalls, but don't worry, they can be fixed :) First you need to look at your application a little differently and start breaking it down into chunks. We can split the chunks in two directions. First we can separate controlling logic (The business rules, data access code, user rights code,all that sort of ...


19

You pretty much can't. Any pirate group who wants to crack your software will, for fun, and then give it to everyone else and there is nothing you can do. Microsoft can't keep Windows off torrent sites, and the UK government can't stop people visiting The Pirate Bay. There's a reason that the new wisdom in many creative circles is to accept piracy and use ...


15

Consider WPF. If you are unfamiliar with WPF, I recommend Windows Presentation Foundation Unleashed. WPF allows for content in web browsers or standard windows applications. WPF also is resolution independent - the content on a mobile device has the same crisp look as the content on a 50 inch tv. Windows Forms is limited when it comes to a highly ...


10

It sounds like what need is to have your programs digitally signed (i.e. Code Signing). This is similar in concept to an SSL certificate, in that it proves that the program is from whomever the certificate was issued to & has not been modified (e.g. malicious code added). The key to understanding Code Signing though, is that the certificates are ...


10

There's a number of ways to control UI complexity. If you have lots of forms, you can choose a design pattern that manages transitions: Application Controller for example, or closer to the metal: State. You can compose groups of controls into single controls. In winforms, you use User Controls. If the complexity is coming from the quantity of code in your ...


9

I'm gonna oppose you with different paradigm : Favor composition over inheritance. Even when you start writing GUI code by hand and use inheritance to share behavior and visuals between forms, you will hit same problem as normal OOP design. Lets say you have DialogForm, that has OK/Cancel buttons and GridForm, that has grid. You derive all dialogs from ...


8

I personally prefer to separate different areas of concern between several assemblies instead of bundling everything together into a single executable. Typically, I prefer to keep an absolute minimal quantity of code in the application's entry point - No business logic, no GUI code and no data access (databases/file access/network connections/etc); I ...


7

Face it: you will be unable to get rid of all pirated copies of your software. Any anti-piracy system can be worked around. A sufficiently interested warez person/group could write a crack which bypasses the activation-related parts in your software. You could write a counterattack to this, and then it becomes a catch: pirates vs. your implementations of ...


7

Using WCF has both advantages and disadvantages compared to direct socket programming. The main advantage is that you do not need to care about programming a server loop or communication protocol. You split your communication into function/method calls, include these functions/methods in your contract interface, create a class that implements it, ...


7

You should concern yourself with data rather than subjectivity. Thus you should be monitoring/measuring/profiling to determine improvements. That monitoring needs to be in both production and test (and dev) environments. Ideally, you shouldn't be optimizing anything until after you see the results of performance. Otherwise you risk a "premature optimization"...


7

You can use a date field as a primary key, but you can't key on PART of a field. You'd have to make a separate field with just the date. This particular condition isn't something that would normally be enforced by building it into the primary key of a table anyway. Your "Employee can't work same shift on same date twice even in two locations" is a business ...


7

Remember that .NET Framework BCL code is optimized for being useful to the largest number of programmers, not for good performance in your particular application. So it's highly likely that you can beat the performance of any particular piece of it, even if you aren't a Rico Mariani. However, you should learn from those experts, in particular mantras like "...


7

Sounds to me that the custom properties are about order processing state. Make a state diagram of your order process. Design classes that move the Order from one state to another, for example from a backordered state to a shipped state. The core Order would be contained w/in each as it is going through that particular state change. There may also be a ...


6

I don't know why you need static controls. Maybe you know something I don't. I've used a lot of visual inheritance but I've never seen static controls to be necessary. If you have a common treeview control, let every form instance have its own instance of the control, and share a single instance of the data bound to the treeviews. Sharing control state (as ...


6

It's very common and I can't find many complaints regarding the speed of Unity/Ninject type resolution. Your classes doing the heaviest lifting that have the most external dependencies you want to inject into should be nowhere near the Windows Forms framework code you're writing and so the fact that you're using Windows Forms shouldn't bare heavily on your ...


6

While KChaloux answer is great, I would like to point out another consideration: List<T> is a lot more powerful than an Array. The methods of List<T> are very useful in a lot of circumstances - an Array doesn't have these methods and you may spend a lot of time to implement workarounds. So, from a development perspective I nearly always use List&...


6

If the UI layer has no access to the assemblies or authentication information needed to access the database, it is impossible to access the database directly from that layer. If you have separated your layers into separate assemblies, and limit the public data types and members to only those needed in the higher level layer, it is easy to detect a violation, ...


6

In case of doubt, ask for clarification. Maybe the UX do not know that these "corner cases" are possible. As for the example that you write, I do not think it so complicated as you paint it. Just from common sense, you have two options: If there are no items for the dropbox, disable option B. Add a tip (when hovering, or with an icon), stating that option ...


6

Displaying a second view on btnShowView2.Clicked is some kind of business logic, so the right place for implementing this is in the event handler of presenter1 which deals with that event (I assume that presenter1 is registered to all relevant button-click events of View1). Lets call it HandleBtnView2Click, so the initial code inside that handler might look ...


6

.net already uses connection pooling, so when you create/dispose a connection, you are not actually opening and closing a database connection, just fetching and returning a connection to the pool. So you don't really get any benefit by changing to Open/Close, and the using construct guarantees that the connection is returned to the pool correctly even in ...


5

I maintain a new WinForms/WPF application based on the MVVM pattern and Update Controls. It started as WinForms, then I created a WPF version because of the marketing importance of a UI that looks good. I thought it would be an interesting design constraint to maintain an application that supported two completely different UI technologies with the same ...


5

There are a number of questions on Stack Overflow that can assist you: https://stackoverflow.com/questions/2317738/how-to-add-help-to-winform-c-sharp-application https://stackoverflow.com/questions/1178922/how-to-add-help-to-windows-forms https://stackoverflow.com/questions/3158901/integrating-help-into-winforms-application https://stackoverflow.com/...


5

WPF strongly encourages using the Command pattern, which encapsulates the logic for a given button press or menu item into an ICommand object, rather than as a code-behind event handler. The interesting part of these objects is that, in addition to the standard Execute method, also has a standard CanExecute method, which determines whether the button is ...


5

In short: It sounds to me like a localization of resources (different types like static labels, text, etc..). Generally speaking, changes in resource file content should not require a re-build of the application. The dis-advantage to store resources in classes, is that each change/modification will require a re-build of the win-form application. Will a ...


5

Most client-server applications can be installed in a "standalone setup", where the client and server machine are the same, as you wrote, but that does not make them a "standalone application". Such a system is still a client/server application, and the interprocess communication between the client application process and the database process will typically ...


5

Patterns Abstract Details, not Vice Versa The clients will behave as "slaves", that is, they will only connect to server and from then on, only the server communicates with them. Eventually the server may request that the clients send "data streams ... MVC and MVP, ... don't seem to be designed to fulfill my specific requirements." I'm getting the ...


5

One can use MVP (Model View Presenter) here. This decouples the view from the view's logic and is typically used to make views exchangable, but there is no reason why it cannot also be used to exchange the Presenter object (in your case one Presenter for each mode). That makes the presenter essentially a strategy object. This will look like this: public ...


4

If you need to have the same control, with the same formatting, etc. in a whole bunch of places, then this isn't a bad idea. However, if each class you create would only be used once, then you're not really removing any complexity, only moving it around. I'd prefer linear, conceptually simple straight-line code to a bunch of classes that are only ...


Only top voted, non community-wiki answers of a minimum length are eligible