Hot answers tagged

47

No, it does not. In C, variables have a fixed set of memory addresses to work with. If you are working on a system with 4-byte ints, and you set an int variable to 2,147,483,647 and then add 1, the variable will usually contain -2147483648. (On most systems. The behavior is actually undefined.) No other memory locations will be modified. In essence, ...


24

Signed integer overflow is undefined behavior. If this happens your program is invalid. The compiler is not required to check this for you, so it may generate an executable that appears to do something reasonable, but there is no guarantee that it will. However, unsigned integer overflow is well-defined. It will wrap modulo UINT_MAX+1. The memory not ...


14

So, there are two things here: the language level: what are the semantics of C the machine level: what are the semantics of the assembly/CPU you use At the language level: In C: overflow and underflow are defined as modulo arithmetic for unsigned integers, thus their value "loops" overflow and underflow are Undefined Behavior for signed integers, ...


10

Ignoring the philosophical question of "to violate or not" (that sounds bad...), you omitted the sentence immediately prior to your quote: The intuitive idea of a subtype is one whose objects provide all the behavior of objects of another type (the supertype) plus something extra. This gives context to why the axiom you quoted was written. Reading ...


7

You can make the code a little more maintainable if you Put the product handling logic (without permission logic and without other side effects) into a separate service class ProductDomain. (See Separation of concerns for details) Create a ProductHandlingService class that uses ProductDomain and applies permissions and other side effects give the ...


4

I think the answer to what you are trying to achieve is how to identify bounded contexts. An aggregate on its own can indeed by thought of as a consistency boundary for all entities and value objects enclosed with in. However, you don't expose your entities directly to the outside world. To apply DDD effectively start by identifying your sub-domains. Find ...


4

When you change the behaviour of a component in your framework, then just unit-testing that component is not sufficient. You must also re-run the integration- and higher-level tests that involve that component to verify what effect your changes have on the rest of the system. If you find that the effect of your change is very large, the either you should ...


4

First (assuming C99 standard), you may want to include <stdint.h> standard header and use some of the types defined there, notably int32_t which is exactly a 32 bits signed integer, or uint64_t which is exactly a 64 bits unsigned integer, and so on. You might want to use types like int_fast16_t for performance reasons. Read others answers explaining ...


4

To further @StevenBurnap's answer, the reason this happens is because of how computers work at machine-level. Your array is stored in memory (e.g. in RAM). When an arithmetic operation is performed, the value in memory is copied into the input registers of the circuit that performs the arithmetic (the ALU: Arithmetic Logic Unit), the operation is then ...


3

When it comes to a large applications with huge database containing milions of records, you soon realize, plain selects, updates, inserts and deletes simply are not enough. So you start thinking in a different way. You create procedures and triggers to take care of more complicated stuff directly in the database and this is not very good. Databases offer ...


3

I think you are confusing a few different ideas here. The repository is usually used an abstraction between the consuming code and the persistence component. Typical methods on a UserRepository would be interface UserRepository { void save(User user); User getById(UserId id); } Operations to change the User would normally be implemented on the ...


2

However, is it reasonable to also create applications using the Component-Entity-System architecture common in game engines? To me, absolutely. I work in visual FX and studied a wide variety of systems in this field, their architectures (including CAD/CAM), hungry for SDKs and any papers that would give me a sense of the pros and cons of the ...


2

Quis custodiet ipsos custodes? Your test framework had bugs in it, which means that your tests were buggy. This is the problem with complex tests and complex testing systems. One way to deal with this is to create unit tests for the complex parts, and then confirm that they behave correctly. In other words, it's just software, and if it isn't dead ...


2

What you're describing is business logic. Purchasing an Item is a business transaction. This belongs in the Service layer. Remember that the Repository layer acts as a facade for persistence, and exists to abstract the underlying details of your persistence mechanism from the rest of your application. The Service layer, by contrast, exposes business ...


2

The responsibility of this class is to retrieve information and output it. In other words, all of the things it does are its responsibility. However, how it does this is its own business and of no interest to its users. For instance, most C programs that produce screen output will eventually call printf, whose code lives in the standard library rather than ...


1

You need Dependency Injection - having the IDbConnection injected to your classes. Here are some quick benefits come to my mind: You only specify the connection parameters at one place - when the IDbConnection gets registered. You have the option to replace IDbConnection with SqlConnection, SqlCeConnection and etc. You have better control over transaction ...


1

The way I normally structure applications is to have all the database access in one DLL (module for other languages). All the data access methods take a connection string as a parameter (in the case of EF its a bit different but still gets passed in based on the connection string in the app.config or web.config of the primary application). This way the DAL ...


1

I saw an interesting talk last year with a couple related papers about using a technique called programming by example on your sort of problem. They had impressive results on spreadsheets, and the technique could probably be adapted to database tables and REST interfaces. The basic idea is the user highlights some examples of the data they wish to extract, ...


1

Load them all in again … but make use of caching more generally in your application. Now you don't have to worry about double-loading. Congratulations: you've just written your first "scalable" application. :)


1

By introducing new public methods, which the extended Controller classes public interface has no idea about, the frameworks break the LSP: I don't think that new methods break the Liskov substitution principle. If you replace the parent with the child a new method won't change the behabiour if treated as a parent class. It just be a ignored method that ...


1

What you have there seems like a standard architectural solution for MVC applications. Since MVC does not provide a solution for the data layer you have a repository. So the 3-tiers are: Business layer: where your classes appended by "Manager" are Data layer: repository Presentation layer: View and Controller EDIT: You should change the word "Manager" ...


1

Here's my opinion on the matter: You have the right idea of wanting to use a webservice, but you may be planning on using the wrong tech. When you say REST, I'm assuming you're talking about Asp.Net WebApi. That's the wrong tech for intranet applications. REST & WebApi are awesome, don't get me wrong, but for any kind of internal application, WCF web ...


1

Look at it this way, it definitely is a common pattern and might reasonably be described as best practice. Depending on your platform you may find tooling that almost makes the problem go away - Microsoft have ODATA support for connected apps that should makes forms over data straightforward once you've climbed the learning curve. More pragmatically - ...


1

You will need to run all tests eventually as you're making a fundamental change. However you don't have to run all tests at once. Rather then fixing the bug, you could deprecate the bug causing functionality, create a new and correct bit of functionality which over time replaces the old functionality.


1

Coarser Objects With Fewer Interactions For me complexity and the overwhelming feeling it causes tends to take on two extreme forms. Note that this is for large-scale codebases, where anything under a million lines of code is not very "large" to me (I once heard someone describe a project with 16k LOC as "large-scale", that seems extremely tiny to me, and ...


1

I'd start with a reverse proxy running Nginx or HAProxy with virtual hosts on a bigger Google Cloud VM. Each of your customers' personal site domains would be directed to the reverse proxy and its virtual hosts would proxy back to the appropriate AppEngine instances. This way you can serve distinct sites with TLS using SNI. Other alternatives include ...


1

I my application, when I create a new person, I use an HTML Now how do I do this with PUT? Where does this go? You don't. If you are using html as your representation of application state, then the links you provide in your hypertext use GET or POST. Yes, you can try to fake PUT/DELETE via post, but the client isn't going to recognize those actions ...


1

The domain model is exposing commands and queries that can be used by the application. So the application (more specifically, the "anti-corruption component") is responsible for taking the DTOs and re-expressing them in a form that the domain understands. If you are building your application from the domain model out, this is really straight forward: your ...


1

Given this lack of behaviour, does a DDD approach make sense? Is the problem that you are trying to solve part of the core of the business? Do you derive a competitive advantage here? If it really is "just a query tool," then no. If maintaining the quality and integrity of the data isn't critical to success, then no. DDD is too expensive a hammer ...



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