Tag Info

Hot answers tagged

9

As lxrec pointed out, it'll vary from codebase to codebase. Some applications will allow you to put those kind of business logic into SQL Functions and/or queries and allow you to run those anytime you need to show those values to the user. Sometimes it may seem stupid, but it's better to code for correctness than performance as a primary objective. In ...


5

Uncle Bob once said: "We don't ship shit...". Working with legacy tools(IE 9) and scraping website you are: Spending significant amount of time on unscalable, potentially unreliable technology. Introducing very custom component understanding which would require future developers a lot of time understand and potentially will cost you a lot more in along ...


4

I find it hard to give general solutions of this kind since system architecture is always highly depending upon the entire domain. If routing packages to employees is a main concern in your system, maybe neither Office nor Employee have to know about how they relate to each other. You could also think about an additional Entity of your system, like an ...


4

Systems such as RabbitMQ (or in your case maybe look into Kafka) can offer persistence, or guaranteed delivery, as well as configurable TTL on messages. However, they are not designed as a long-term persistent storage solution, and if we're talking about days, I would actually store the job in a DB as you suggest.


4

In this case, CalcFoo() should take in an OsEarnDetailPoco. The method signature then becomes CalcFoo(OsEarnedDetailPoco data). Services are typically injected in a DI architecture. Data is usually passed around through method calls.


3

You say that the example is artificial, so I don't know if what I'm saying here suits your actual situation, but my answer is - use an ORM (Object-relational mapping) layer to define the structure and querying/manipulation of your database. That way you have no duplicated logic, since everything will be defined in the models. For example, using the Django ...


3

How can I convince them that this is a bad idea? It might not be a bad idea. I've seen not a few systems where each event got its own tiny handler class, and the handlers were discovered and dependency injected at runtime leading to a fairly huge fragile mess. Without knowing what you need to do, and what you might need to eventually do, it's hard to ...


3

At a high level, you're essentially asking: Is building a Controller cache better than using singletons? I would argue that in your situation, yes, it is. And here's why. From your description it doesn't sound like you need the semantics of a singleton here. Your game would be just fine if you instantiated a new Controller every time one was needed. In ...


3

In an app like this the "tiers" are usually various parts of the same application. You could write it as multiple JARs packaged into a single deployment, but the different tiers are more about separating the different concerns in the code than putting physical distance between them. If you were to put the data access on a separate machine, you would need ...


3

This is related to constraint-programming. Prolog is an example of such a system. There exists javascript implementations of prolog http://yieldprolog.sourceforge.net/ . You could then make your prolog program and use it on both the server and client. Another approach is having all the logic on the server side but expose it as an api which the client could ...


3

In a Microservices architecture, each one is absolutely independent of the others and it must hide the details of the internal implementation. If you share the model you are coupling microservices and lose one of the greatest advantages in which each team can develop its microservice without restrictions and the need of knowing how evolve others ...


2

One thing I see with the first example that could lead to confusion is that the Employee is not sending the package, they are receiving the package. I think the send method leads to confusion that the Employee is sending the package, when the Employee is receiving the package. I think the second example is better. The SomeOffice class has a reason to keep a ...


2

If you want consistency, then using a class for each error condition gives you just that - wherever you want to mention that a volume has grown in size, you create an instance of a VolumeSizeIncreased class, passing whatever values you need into its constructor. To me, it's the next step after rigidly codifying your errors (your VOL_SIZE_INCREASE value). ...


2

There are several ways to look at this. One way is from the point of view of data abstraction. (I'm going to ignore looking at this from the perspective of programming paradigms, since @Robert's answer already does a good job.) The two most popular forms of data abstraction in use today are Abstract Data Types and Objects. (Actually, there is a rather ...


2

First of all, don't confuse OO modeling with OO programming. Most modern programming languages are more or less OO and can be used to implement most designs whether they have been derived using OO modeling or not. I can write a program following a relatively procedural design (or event-driven, or some other style) and still use Java Collections with their ...


2

There is an anti-pattern - God Object. Just like you stated, God Objects: are hard to maintain usually violate one or many SOLID principles. impossible to understand for new developers hard to locate functionality in for new developers do not describe system at first glance at file structure etc. Having module controller is quite OK actually, something ...


2

The usual approach is to isolate those microservices as much as possible - treat them as single units. Then transactions can be developed in context of the service as a whole (ie not part of usual DB transactions, though you can still have DB transactions internal to the service). Think how transactions occur and what kind make sense for your services then, ...


2

If two services are sufficiently intertwined that it would be a pain to implement them without sharing DTOs and other model objects, that's a strong sign you shouldn't have two services. Certainly the example makes little sense as two services; it's hard to imagine a specification for 'User management' so complicated it would keep a whole team so busy they ...


1

I think if consistency is a strong requirement in your application you should ask yourself if microservices is the better approach. Like Martin Fowler says: Microservices introduce eventual consistency issues because of their laudable insistence on decentralized data management. With a monolith, you can update a bunch of things together in a single ...


1

I think the standard wisdom is to never have transactions cross microservice boundaries. If any given set of data really needs to be atomically consistent with another, those two things belong together. This is one of the reasons it is very hard to split a system into services until you have fully designed it. Which in the modern world probably means ...


1

You can have as many models as you need to meet the many goals that a successful application has to address. One concept that might help here is the Single Responsibility Principle. Basically, you ask the question, "what would cause this data structure to change?" In your case, changing the details of the quiz structure would be a prime source for change. ...


1

An application is called memory-bound if it requires a lot of data from memory, so most of its execution time is spent reading and writing data. Latency-bound can be thought as a subset of the memory-bound category and it occurs primarily when you don't retrieve too much data from memory at once, but you have to wait a lot to get the data close to the ...


1

I've written a silly example to explain an idea: class BinaryIntegerOperation { public int Execute(string operation, int operand1, int operand2) { var split = operation.Split(':'); var opCode = split[0]; if (opCode == "MULTIPLY") { var args = split[1].Split(','); var result = ...


1

First thing you should check is how many lines of code a typical Organization class implementation has, and how it is structured. If it has less than 100 lines of code, and the class consists mainly of properties providing some flags or data, do not worry. If it has more than 2000, and it contains a lot of business logic, you should consider to split it into ...


1

I think you are almost there. You are getting the State and the Strategy. The way of selecting maybe would be a Factory or a Builder maybe reading a configuration file or a database just as you pointed. At the end it will depend on your own requirements, but the strategy mixed with the Factory or a Builder Pattern to create the object which contains the ...


1

I would define "application core" as either code or library, that every other code or library depends on, and without it, it cannot function. It should contain only critically necessary features that your application needs to run. It shouldn't contain any domain logic nor models. In case of the article, it seems the "application core" is primarily managing ...


1

A Factory or Factory method is a way of creating objects without having the calling method be aware of the specific class of object that is being created or the dependencies it has. It takes away the complexity of instantiating objects for which (some of) the properties are not known at code-time but can only be known at run-time. Your Entity Translator ...


1

Consider the three pillars of OOP: Encapsulation: The capability to hide data and instructions inside an object Inheritance: The ability to create one object from another Polymorphism: The ability for objects of a derrived class to override/extend/inherit properties and methods from a base class If these benefits do not offer any real value to solving ...


1

The send function is a red herring, because it is unrelated to the basic question, which is whether you should have each employee know their office, or whether you should have each office know which employees are in it. The send function does not affect, nor is it affected by, the answer to the basic question. It probably should not be a function of either ...


1

The best logging is just to format it as a readable string and persist that. Possibly including the data as a block of data that is accessible to programs as well. The reason I say this is that I am continually looking at Windows Event logs, which uses a "we write the data and a link to a resource dll containing format strings" pattern, and invariably the ...



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