Tag Info

New answers tagged

3

50 applications in 6 weeks sounds enormously ambitious. You need to tell your new CTO that this is only a lightweight review; there's no way you're going to detect bugs or security flaws in this time. I'm mostly familiar with code review for security, and the rule of thumb I use is 10 KLOC per day - and even that is ambitious, and can only be achieved by ...


4

I believe you misunderstood the recommendations for logging. The 12 Factor site states A twelve-factor app never concerns itself with routing or storage of its output stream. It should not attempt to write to or manage logfiles. Instead, each running process writes its event stream, unbuffered, to stdout. During local development, the developer will ...


3

It looks like you are confusing your underlying model objects with your API resources, they are not necessarily mutually exclusive. If you are simply serializing your classes as JSON, you going to duplicate content (and get the profile appearing several times) which is not needed and a smell. You could: Create specific resource models that represent your ...


2

We have a cluster-environment too. We use Hazelcast for such jobs. With Hazelcast you could embed the codeblock for updating within a "Hazelcast-Lock-Section". It is not my favourite solution, but this is how it is done in our application (and maybe suits hazelcast your needs). I opt for a smaller and easier solution: I would write a small (buzzword-alarm: ...


1

Using a messaging broker seems like the best tool to inform other applications that they should update rather than polling (which is fine really too). http://www.rabbitmq.com/ Locking the database table for writing is what you want to prevent race conditions.


23

What is more important and significant about a microservice: its API or its database schema? The API, because that is its contract with the rest of the world. The database schema is simply a convenient way of storing the data managed by the service, hopefully organised in a way that optimises the microservice┬┤s performance. The development team should be ...


28

Databases are not very good at information hiding, which is quite plausible, because their job is to actually expose information. But this makes them a lousy tool when it comes to encapsulation. Why do you want encapsulation? Scenario: you tie a couple of components to an RDBMS directly, and you see one particular component becoming a performance ...


11

Microservice Architecture is hard to describe but the best way to think about it is a marriage between Component Oriented Architecture and Service Oriented Architecture. Software as a suite is composed of many small business components with a very specific business domain responsibility. Their interface to the outside world either in provided services or ...


1

Here's a twist on Matt's answer, using the builder pattern combined with Java 8's new functional capabilities: Book.java import java.util.*; import java.util.function.Consumer; public class Book { private String title; private List<String> authors; private int year; public Book(String title, List<String> authors, int year) { ...


3

Depending on the number of fields, you might find it easier to use the Builder pattern to combine these changes than to create a separate constructor for each possible set of changes. It does requiring one object that is not going to be used (returned), but you can use one builder instance for as many books as you need to change. public final class Book { ...


2

One useful pattern is to define a public interface which can report all of the properties associated with the class, as well as a package-private interface which extends it with a few additional members. A package-private version of the class should be mutable, but the public-facing one should be immutable. The public-facing class should hold a reference ...


0

I think solution 2 is the better solution. You want to avoid treating connection commands as special cases. That would add complexity to your script engine and/or script language. Your commands should receive a general purpose execution context (or script state). Some psuedo-code could be: interface ICommand { void Execute(IScriptContext context); } ...


0

I think a minor detail was not mentioned in the other answers: The reason that the .com TLD is the most popular one, is that in the early days of the Web, Web-browsers like Netscape Navigator "auto-appended" .com if it was missing in the address (eg. if the name-lookup failed). So if you typed "shareware", it would be expanded to "http://shareware.com" (or ...


1

You don't have to change existing code, because you can just add more event handlers. JavaScript naturally supports multiple event handlers on a single element, and it's even easier with libs/frameworks like jQuery: // in existing code: $('#button').on('click', function (event) { console.log('normal behavior'); }); // somewhere else: ...


1

The presence of a service layer does not necessarily imply the model is anemic. A service layer might provide a simplified facade to a complex domain model. I.e. a business user may just want to create a new poll. The UI is simplified if it speaks in those terms and the service layer would translate from what the UI understands into operations leveraging the ...


1

There's a risk that the second approach leads to a Fat Controller, which is often considered an antipattern. It's effectively a violation of "clean architecture" (as by Uncle Bob Martin) since your controller is now not only a "delivery mechanism" but also deals with applicative transactions/use cases, orchestrating calls to the repositories and services and ...


2

As long as you are the only vendor for all "plugins", and as long the invidual modules don't need hundreds of MB disk space, I suggest you put always all DLLs into every released package, and treat everything as one product, with one version number. This makes deployment easier, since you don't need separate packages for partial updates, and if you need a ...


4

I would take an approach that shared libraries are the responsibly of the core, and that modules can be updated however they want on an individual basis except when that requires an update to a shared library. Additionally, I would track versions of the libraries by keeping a single version number for the core platform which is incremented at each release, ...


7

At some point, every project becomes too large and complicated to keep it all in your head. For some this point comes sooner or later than for others and you seem to have hit that point in your project now. The first step now is to start writing that dreaded documentation. Write down what each class is supposed to be doing, which classes work together ...


0

If you group your technical meta data (as you call it) into reasonable classes, I do not see a problem to be part of your Book. There is just a problem if some of your meta data is needed during the model creation. If this is a case, then you can't run from factories - or to have instance to providers of those meta data.


2

The difficulty is that you have to deal with already complex rules which change every month. I would think of two techniques which can be used to mitigate some complexity: Don't store historical rules in code. Unless there are a lot of accounting errors and your company needs to recalculate the payroll often, you don't need to keep all this complexity. At ...


0

Not necessarily. Middleware cannot handle everything. There are three examples I always bring up to show this: batching, forwards and api chaining. These all benefit by staying within the bounds of the original request but in applications, often have to leave and come back in via the proxy/api gate. By abstracting I/O from the api and moving it to an ...


2

I had a similar problem with my code with global state via singelton. As @Thomas-Junk-s and @SHODAN-s comment suggested i refactored my code to make the static global state non-static through constructor Dependency injection. Example original code public static class Global { public static int getSomeGlobalState() {...} } public class MyClass { ...


0

Yes, it's better not to share state between unit-tests, and have them independent from each other. But it doesn't mean that you can't share code between unit-tests. For example(using NUnit + FluentAssertions + FakeItEasy): [TestFixture] [Category("Unit")] public class when_rolling_back_unit_of_work : UnitOfWorkScenario { [Test] ...


-2

It doesn't seem to me these layers are really separate unless they are different applications entirely. Though the idea of separate classes like BL and DAL etc sounds good, I rather think the UI should only handle UI functions and receive from the BL only strings and numbers in an expected order to be passed into the appropriate controls. The BL can ...


0

Number 1 jumps out as an elegant way to do this. Can you elaborate on why Event Sourcing would result in the same emails being sent multiple times ? ES systems normally have ways to distinguish between when an event is raised for the first time and when it is reapplied later. See line 90 of this code from one of Greg Young's repos. 2 . is also an option if ...


1

Some considerations: Choice of database: relational databases such as Mysql or Postgres are not necessarily harder to scale than MongoDB and such. In many cases it's quite the opposite. Here is a great comparison of different storage technologies: http://kkovacs.eu/cassandra-vs-mongodb-vs-couchdb-vs-redis "Event-driven" architecture: You have a lot of ...


2

I'm in the "thin controllers" school of thought -- or in this case the service should be responsible for all persistance operations -- the controller is just there to be a traffic cop between HTTP requests and the service layer -- sending input in, interperting results out and doing the right thing. On the flip side the service layer should be blissfully ...


1

I don't recall seeing the specific Views -> Dispatcher -> Stores architecture before, but the more general concept of a "flow" has been around a while, as they mention in the article you linked: This structure allows us to reason easily about our application in a way that is reminiscent of functional reactive programming, or more specifically data-flow ...


1

I would allow authorization code to grow into business logic only as long as it is business-related, that is, with regard to actor business roles (RBAC). But then it's rather business rules validation with authz effect. Otherwise I do authorization checks primarily at the controller level. It's easier to maintain if you know that all of your authorization ...


1

I think it's absolutely reasonable approach to engrain authorization in your Service layer. You need to protect your service from performing unauthorized activities(especially data-modifications). Your Service layer could resides in one library, and being used by different Presentation layers(you could have different UI-applications, that use the same ...


1

In my experience, if a result is needed in multiple places in the user interface, this suggests to me that the method for calculating it is a universal business rule, and therefore that rule has no business being implemented in a single presenter: it should be part of the domain model, instead. At that point, no communication between presenters is needed, ...


3

Decoupling components from the database / getting away from direct database connections is a common pattern. Moving access into middleware / a component that front-ends the database can help improve security and modularity, and provide a place to implement data validation and interpretation that would otherwise "fall into" SQL, stored procedures, and ...


3

I think the overarching justification out of making data access a RESTful API would be the relationship the data access would have to the rest of the environment. Think about it, the power of the API is typically the vast amount and variety of "client" implementers that can consume it. That should be no different in your case. In other words, if you were ...


0

you can think of App Servers as a sort of super version of JDBC or ActiveRecord or whatever it is you use. Some applications won't need that separation, and if this is your first pass, as mentioned, don't worry about it. However, if you find that the logic responsible for interacting with the database is getting very complex, it can be useful to split that ...


6

You original question seemed to reflect a misconception - one of top 10 false assumptions about OO: the belief that object orientation will imply more code reuse and less duplicated code. That is a fallacy! If you have devs who care for DRY code, care for reuse and who have learnt and understood OO principles, they can use the latter to build better, more ...


1

All I can see above is just an application of the strategy pattern. How much you have to extend this code to make this a real "plugin architecture" is debatable, but IMHO the central point is to have the deployment of new billing system implementations decoupled from the deployment of the main system. Ideally, you, your team, or a third party can deliver ...


1

1 of course would most likely be the easiest option to implement. 2 is a reasonably common practice to help deal with slow or hard to deal with systems. And your right it does duplicate the data, so you would need to have the policy that System B is the authority and A should be used as 'read only'. I personally would go for option 3, with slight ...


0

I'll note that I like email as an interesting example of a very successful asynchronous messaging system. That said, the primary means of data transfer isn't a suitable task for email for a number of reasons beyond "it feels dirty." In fact there are two good arguments against this: Delivery guarantees -- you can read the RFC for details but basically ...


2

I assume this is an existing solution based on your last sentence, if so, and it works, then what is the problem? Sometimes the urge to rewrite is the wrong answer. (I say sometimes, I mean always). Its not the solution I would have come up with, but if it works, and I can't see why it wouldn't - email has mechanisms for delivery and retries, and if its ...


6

There are advantages to using email in this kind of scenario. Primarily, it allows the machine that hosts the service to be available only intermittently and still get the job done. You can think of it as a kind of poor-man's message queuing. Also, it allows the service host to sit behind a firewall and only pull in requests from a mailbox on a trusted ...


1

This kind of solution does not necessarily have any problems, and it could have been created in a robust manner. In fact, there may be indeed situations where this is a preferable solution. However, there are many situations where this has the risk of becoming overly complicated. Alternative solutions use Web Services. They work better for this purpose, ...


0

The reason is that SQL databases store the objects in a relational way - items are stored in different table than aggregate root and they reference back to aggregate root by IDs. So using of MySQL requires to model items as entities that are persisted in separate table where they obtain primary id (with auto increment). In key-value stores eg. MongoDB one ...


0

It looks enough for me in general but i will try to dive into some details as you know the main issue here is to make sure the system is using the wanted most updated version of data in both B and A, in case of conflict which one will be the master? imported data or existed data you need to highlight this and move on. more to say: A data is integrated with ...


-1

Visitor Pattern Comedically, and with good fortune, I found the above Wikipedia article that precisely describes my situation (what are the odds?). Consider the design of a 2D CAD system. At its core there are several types to represent basic geometric shapes like circles, lines and arcs... one could apply the Visitor pattern. The Visitor pattern ...


2

Why do you need the mother of all base classes? Isn't that sort of what object is for? Seems to me like you have two problems here. You have a base class that is too general, and you have classes for EmailFrom and EmailTo which are too specific. Your base class should have a name that suggests its purpose. Atom doesn't do that. And EmailFrom and ...


0

In many 32-bit machines without a memory cache, the memory will be divided into four 8-bit-wide sections, each of which will be connected to eight bits of the system bus and will have its own "enable" logic. If a processor executes a 16-bit store instruction, it will enable two of the eight sections and output the appropriate data on the wires that connect ...


0

Have a look at the Python argparse and cmd modules. If you'd like to make an interactive UI, subclass cmd.Cmd and for each of the commands, you can use argparse to parse the subcommand and options. import readline # for history and autocomplete import cmd class MyShell(cmd.Cmd): def do_add(self, line): "adds various things" print "add ...


0

Choice has Reference to Question Makes sense if this is a composite, vice an aggregate. Inadequate Requirements Analysis Don't compose Aggregates with other Entities. Just have a root Entity and value objects. Use reverse relationship to express the connection between aggregate roots. Make sense? No, it does not. It's not possible to make ...


0

You need to build an XMPP compatible client or use/modify an existing one. Using the REST API will complicate things. Setup the ejabberd server and follow a normal client/server architecture. It has multiple modules for example for authenticating users through your normal database , saving messages in different databases etc.



Top 50 recent answers are included