173

I don't really intend this to be a bashing answer, but these are the reasons I do not personally use Qt. There are plenty of good things to say about it -- namely that the API works most of the time, and that it does seamlessly bridge platforms. But I do not use Qt, because: In some cases, it just doesn't look like native programs look. Designing a single ...


158

The principles stated in "Clean Code" are not always generally agreed upon. Most of it is common sense, but some of the author's opinions are rather controversial and not shared by everybody. In particular, the preference for short methods is not agreed on by everybody. If the code in a longer method is not repeated elsewhere, extracting some of it to a ...


145

Return an Empty Set I would expect an empty set because: There are 0 combinations of 4 numbers from the set of 3 when i can only use each number once


114

As people say, each tool fits to each problem and situation... But if you're C++ programmer, Qt is your framework. No rival. We develop a complex medical imaging commercial application, and Qt holds on. I don't say that the 'cons' that people say about it are false, but I have the feeling that they don't have tried Qt for a long time (its continously ...


93

Because when those libraries were written, some major browsers did not support those features. Once written and used, these features cannot be removed from these libraries without breaking many applications. (In this case, "major browser" means a browser that still has large market share, which includes older versions of browsers like Internet Explorer, ...


89

Let's talk about cars. Oh wait, we already did - remember that time we met, some time ago? We talked about cars. In fact, you seemed to be quite the expert on cars. You were able to explain, in detail, all of what's right, wrong, and exciting about the latest Formula 1 race. You knew by heart all of Lamborghini's models, including their price and ...


84

Good answer here already, but let me say a word about your butterknife example: though I have no idea what the code does, at a first glance, it does not look really unmaintainable to me. Variables and method names seem to be chosen deliberately, the code is properly indented and formatted, it has some comments and the long methods at least show some block ...


79

When in doubt, ask someone else. Your example function has a very similar one in Python: itertools.combinations. Let's see how it works: >>> import itertools >>> input = [1, 2, 3, 4, 5] >>> list(itertools.combinations(input, 2)) [(1, 2), (1, 3), (1, 4), (1, 5), (2, 3), (2, 4), (2, 5), (3, 4), (3, 5), (4, 5)] >>> list(...


78

As a general guideline, libraries should be totally disconnected from the environment. That means that they shouldn't perform operations on standard streams, on specific files, or have any expectation about the environment or the context they are used. Of course, there are exceptions to this rule, but there must be a very good reason for it. In the case of ...


73

Shading dependencies is the process of including and renaming dependencies (thus relocating the classes & rewriting affected bytecode & resources) to create a private copy that you bundle alongside your own code. The concept is usually associated with uber-jars (aka fat jars). There is some confusion about the term, because of maven shade plugin, ...


72

In layman's terms: If there is an error, you should raise an exception. That may involve doing things in steps instead of in a single chained call in order to know exactly where the error happened. If there is no error but the resulting set is empty, don't raise an exception, return the empty set. An empty set is a valid set.


54

As an engineer, perhaps it is suitable to think of this as an optimization problem. Naturally we must have an optimization goal. A common one in this sort of situation would be to minimize Total Cost of Ownership. If you believe adding the third party component will save cost in the long run, you should use it. If you don't, you shouldn't. Make sure you ...


53

I agree with Ewan's answer but want to add a specific reasoning. You are dealing with mathematical operations, so it might be a good advice to stick with the same mathematical definitions. From a mathematical standpoint the number of r-sets of an n-set (i.e. nCr) is well defined for all r > n >= 0. It is zero. Therefore returning an empty set would be the ...


41

One of the advantages of header-only libraries for C++ is that they do not need to be compiled separately No, that is not an advantage, quite the opposite - the main part of the library has to be compiled as often as it gets included, not just once. That will typically increase compile times. However, if you are referring to the advantages listed here in ...


36

Bill Gates once famously said: "Measuring programming progress by lines of code is like measuring aircraft building progress by weight." This quote comes to mind because the same could ultimately be said for the number of libraries. As a rule, I don't use libraries unless: There's no other way of getting it done. Doing without would no longer be ...


35

Of all the things I don't like about Qt, the fact that it doesn't play well with templates bugs me the most. You can't do this: template < typename T > struct templated_widget : QWidget { Q_OBJECT; public signals: void something_happened(T); }; It also doesn't play well with the preprocessor. You can't do this: #define CREATE_WIDGET(name,type)...


35

Because different browsers have different implementations and features baked in their JavaScript engine. The same "vanilla-JS" code could run differently on two different browsers, or even two different versions of the same browser. The abstraction layer provided by popular JS libraries is a way around this. Behind the scenes, it works around the different ...


34

Summary As JacquesB writes, not everybody agrees with Robert C. Martin's "Clean Code". The open source projects that you found to be "violating" the principles you expected are likely to simply have other principles. My perspective I happen to oversee several code bases that adhere very much to Robert C. Martin's principles. However, I do not really ...


33

The "simple is better" mantra has become too much dogmatic. Simple is not always better if it complicates other things. Assembly is simple - each command is much simpler than higher-level languages commands - and yet Assembly programs are more complex than higher-level languages that do the same thing. In your case, the uniform handle type enh makes the ...


31

Both OpenGL and SDL are C libraries and expose a C interface to the rest of the world (as pretty much every language out there can interface with C but not necessarily with C++). Thus, they're restricted to the procedural interface that C gives you and the C way of declaring and using data structures. Over and above the "interfacing with other languages" ...


31

The best place to start is probably the "design philosophy" section of the user guide. But to lay out specific differences between Noda Time and Joda Time: Noda Time keeps much more of its code internal. This makes it less flexible, in that you actually can't create your own calendar system - but also means the API is simpler both to learn and use. Nullity ...


28

One reason to not use Qt is that if you only write for one architecture, such as Windows, you may want to use C#/.NET (or Cocoa on Mac) because they will invariably be able to take advantage of the latest bells-and-whistles of the OS. If you are writing cross-platform apps, then you may already be heavily vested in another technology such as Java (i.e. you ...


27

1. Backwards compatibility JavaScript is an implementation of ECMAScript. Most of those functions were introduced in ECMAScript 5 (ES5) however many older browsers which still have a significant enough share of the market do not support these functions (see ECMAScript 5 compatibility table), the most notable of these being IE8. Generally libraries will ...


26

Some of it is licensing. See https://en.wikipedia.org/wiki/Qt_(software)#Licensing for some of the licensing history. Until 2000, people who cared strongly about open source, did not use Qt. Period. (This was, in fact, the original motivation for the development of Gnome.) Until 2005, people who wanted to be able to release free software for Windows did ...


25

There are numerous reasons to create libraries & shared libraries, (in .dll or .so files) even for internal usage: Re-Use across projects is much cleaner Separation of responsibility - part of your code may be more suitable different developers or teams You can benefit from improvements in the libraries that other teams make without having to locate the ...


24

I find a good way of determining whether to use an exception, is to imagine people being involved in the transaction. Taking fetching the contents of a file as an example: Please fetch me the contents of file, "doesn't exist.txt" a. "Here's the contents: an empty collection of characters" b. "Erm, there's a problem, that file doesn't exist. I don't know ...


21

If the contract expects source code to be delivered, then the source code you give them should compile. Not giving them the libraries to do this is ridiculous. If the code in your libraries is generic helper type code, then there is nothing wrong with giving them the binaries and some license agreement with them. If the libraries contain something ...


21

You should put the unit tests in the same repository because otherwise someone has to answer to the question "Where are the tests?" every time the project is handed over from one person to another. References to other repositories tend to get invalid over time when repositories are relocated and people change from one version control system to another. Just ...


21

There are well-established patterns for attributing the libraries you use. In general, you put this attribution in the same place where you'd put your copyright notice. In a desktop application: Often there is a menu item “Help > About”, which displays a small info window with the application name, version number, copyright, and developer contact. This ...


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