New answers tagged

0

I had the same request, and found these references that could help you. Java + MongoDB + Elastic Search = River Plugin you can find at https://github.com/richardwilly98/elasticsearch-river-mongodb/wiki And if you are really going to have a gorgeous amount of data to manage, so please read this interesting experience and the conclusion of the Quark'sLab : ...


0

I don't know Flux, and my answer is "it depends". Edit with summary: I would choose between either (A) including attendee resrouces directly under meetings (and not optimizing as you have done), or (B) not include them at all and only provide URIs of the attendee resources. Choice (A) is a reasonable compromise in my eyes. If you're aiming to be as RESTful ...


1

I do like David Packer's answer on your other question. But to distill it a bit more: Some Business Logic on front end to reduce round trips. But all Business Logic on back end (which, yes, means you will have duplicated business logic) Also, forget about how difficult or not is to implement it on a language. You are taking an architectural decision ...


0

Each system maintains a changelog of its database. We are planning to implement it with MongoDB. You can use an eventstore. There any update to data will create a new event in the store. When a system initializes a synchronization process, it retrieves all made changes from log. If the system is B, the changes retrieved depend of the destination....


1

If you are using a database which supports transactions, then just upload the components in the same transaction. They won't be visible to the application until the transaction is committed, which will be an atomic event. Search for "database ACID" for more details. Alternatively, ensure all the resources for the page are in place before adding the HTML ...


2

Answering the questions an order that makes sense to me: Are the identified processes sensible, or are they too abstract? The items on your process list are rather brief and looks to me more like scenario heading names than processes. As I read it, in 4+1 processes are essentially running programs. ... At the highest level, the process ...


1

There's a UI right there. You can see it has both text and image elements. Though, in the end it's all image. The searchable, selectable, and copyable text you see me typing right now ends up being an image on your screen, though unlike the image above it's sent to your computer as text. Your computer converts it from text to an image to put it on your ...


0

There may be another solution than one proposed by Ewan, though his is excellent. Suppose you have a pool of queues. At any moment, a queue is either free (not being used at all) or assigned to a specific bank account. You still need a master worker to allocate a queue for use, assign it to a bank account, and make it available to the next free subordinate ...


1

So, You have two issues here 1: Prevent/Resolve Simultaneous actions (withdrawals) on a single resource (bank account) 2: Enforce processing actions (withdrawals) in a particular order In your example, you could resolve 1 in a number of ways, but lets take the simplest. Processing the withdrawal calls ReduceBalance(accountId, amount) on some bank account ...


1

The guiding principle at work here is probably "if you ever need to run a query on the data, and not just display it in its native form, then the data needs to be first-class rows and columns, not some JSON stuffed into a single field."


1

This question states an incorrect premise as fact, then makes an argument about that incorrect premise. Lets dig in to this .. "all their design points to minimizing GC use" - simply isn't true. The innovation in the disruptor has little to do with GC. The disruptor performs because its design cleverly considers how modern computers work - something that's ...


0

Is there a long term disadvantage to having the seed data in classes in the code, and if that's the best place to put it I would argue that, on the contrary, this is the best place to have this kind of initialization. Since your code depends directly on this data, its shape and contents, this initialization being directly tied to your code is actually the ...


2

Change the hardcoded endpoint so it can be changed. Read the endpoint from a file containing all your settings. Its pretty easy to do, and allows for other settings to be changed according to other parameters. Possibly the easiest thing for you to do is to read the file if it is present, or default to a fixed value if not - this allows you to drop a new ...


0

I gotta admit that I already have one suggestion and I'm posting this question to see if anybody has a better idea. Rewrite the applications so endpoints are not fixed, and the base API URL is defined in a single property with the default value being "http://api.mycompanyname.com" Implement a "dev mode" property in applications. If this property is turned ...


0

When you call an API through https, you can get the following answers: Internet is down. Cannot connect to the server. https failed to negotiate (after reaching the server). A nonsense answer when you use http in a Starbucks. The server tells you that the API is currently down. The API tells you that it isn't working right now. The API gives one of many ...


0

I don't think there is a definite right answer. It depends of course. If I were you I would think about what the ideal user experience would be when this happens. Then do whatever it takes in your application to make that happen. You could just throw an error and tell the user to try again later. Or if it's an issue that happens sporadically, just retry the ...


0

If you can't rely on the 3rd party API to give you a response (and you're accessing it synchronously) you can set a time-out. I would access the 3rd-party API on a separate thread (or even process) and wait for the response with a time-out set. If the time-out expires, just move on. Additionally, I had a very similar problem a while back. Feel free to check ...


0

If you're giving flow of control to the API the response is to wait until hell freezes over, or the user presses ctrl-alt-del. If you're calling it asynchronously the typical strategy is to timeout. If the API throws an exception, easy: clean up, log, and display the error. Whatever you do, don't fail quietly. I hate debugging things that fail quietly. ...


1

Since you want to be able to launch multiple instances of your monitoring application and be able to use the solution even if no one is "listening", eventually all of the data needs to get distilled into some sort of central data store (data base, flat file, in memory in some central application). Personally I would stand up a web service for your logging ...


0

Associate the token with the source IP address of the request in addition to the username when saving it to redis and when looking it up while authenticating a request. Remember to handle the case where you have a cookie but it doesn't match the token associated with the request's source IP address, authentication should fail in that case.


0

According to the comments, you have a caching system which relies on: A common Redis cache service used by all the servers, An in-memory cache on every server which somehow duplicates some of the Redis data. Information stored in this cache is subject to inconsistency, and you are looking for a way to prevent this inconsistency. First and foremost, you ...


2

A few assumptions: Microservices can communicate between themselves Implementations of each microservice are not relevant to the external world (this is even easier when abstracted into a container) Imagine a client/server interaction, the client/server might communicate with a JSON API. Or a message broker. The specific implementation does not matter, ...


0

Change the scope of the field. If the name matters and that behavior should be tested, then make that field public. In this case, make it public read only. Then one will be able to test the state of the object after the constructor is fired.


6

If it is the case that the name of the car isn't publicly available in any way at all, then it makes no sense to test it, because obviously it doesn't matter to any client code. If the name of the car matters, even if you can't actually see it by inspecting the field, then exercise some method that relies on the name being correct and assert against some ...


0

When coding software, should the architecture always be best practices or practical practices in regards to the application being built? In Theory, yes. In the Real World, [still] yes, as long as you can afford to do so. Which, of course, means, "No". Time and money pressures will always try to push you down the road of a "quick and dirty" solution, ...


0

In my experience there is only one best practice that I consider to be mandatory: Keep It Simple, Stupid (KISS) In other words: Whatever tools, APIs, architectures, etc you choose - if you keep it simple, it's more likely to be easy to work on the future, have less bugs, be fast, memory efficient and everything else you might desire. All those other ...


1

I'll try to view from a different perspective. Today's modern frameworks make it very easy to setup a basic project with mvc, dependency injection, layered architecture etc. (spring boot lover here). I'd say start with a generated base and use the tools provided for you, until you bump into something that requires a handmade solution. Then you may cut ...


1

A design principle for me for microservices is to have each service as decoupled as possible from other services. That allows you to deploy and upgrade a service without worrying about breaking other services. A black-box library of functionality (your option 3) seems like a viable option. That being said, I would go with option 2 until you have a good ...


2

No. Best practices are things that are generally considered to be the best thing to do 99% of the time, but that doesn't mean they always apply to every situation. As a developer your job is to know and use those best practices, but also know when it's safe to cast them aside. This isn't supposed to be self-promotion, but I recently wrote a blog post ...


2

I assume by "best practices" you mean some list of rules that someone wrote in a book. For of course if you mean the phrase literally, then of course you should always write the best code you can. Need I point out that there is not a single, universally-accepted set of "best practices"? For any rule promoted by one expert, you can almost always find another ...


1

Some things are important, some aren't. You should tailor your choice of language and style to the problem at hand. For instance, a "Best Practice" for exception handling might be to always catch exceptions and log them, but when creating a unit test the best practice is often to let them throw out so the unit testing framework can report them correctly. ...


1

By best practices, I'm assuming you mean "informal rules that the software development community has learned over time which can help improve the quality of software" and not some sort of literal best way of doing a specific task. Yes, until you have a reason not to. It should be a good reason that you've given serious consideration and applied to the ...


0

The best "Best Practices" always contain a section that you should use your intelligence and experience to identify when the items in the manual are inappropriate. They may also contain a section on reviewing, approving, and documenting such exceptions and making them part of the "best" practices.


11

The best practice is the one that most effectively fulfills your software's functional and non-functional requirements for features, maintainability, performance, etc. If that practice happens to align with some "industry standard," that's awesome. But if it doesn't, pragmatism wins. Where I currently work, we're building a new web UI for our product from ...


40

Should coding best practices always be used Always? No, that's silly. Best practices are guidelines. For most people, for most situations, if implemented with some finesse, they will yield the best results. They're where you start when considering solutions. But there will be places where best practices can and should be ignored, because there are better ...


30

Yes. That is self-evident. Why would you not do what is best? That's not the issue though. The hard part is finding out what IS the best practice, because in order to answer that you need to know exactly what requirements you have and how the project is likely to evolve over the years, and that is fiendishly hard. One good rule of thumb however: It is NOT ...


1

Unless someone has a really unique way of addressing this problem, I would think they would buy something already built because there are security issues along with established ways of doing this. First of all should I use NoSQL or SQL for this kind of architecture? From an architecture standpoint, both will work, so consider security as a prime ...


3

Layers, Onions, Ports, Adapters: it's all the same Since this article makes clear that onion is equivalent to 3 layer + application of the Dependency Inversion Principle (DIP), then the question becomes "where should I prefer to use DIP?" I'd say any non-toy project. Using DIP allows the core of your code to be more isolated, testable and maintainable. When ...


1

This data can be expressed well in a relational database, so a document based database doesn't really offer an advantage Using the database's querying features to narrow down the booking to the doctor and date(s) you're interested in and doing the actual processing in the application should work well. There are perhaps a few hundred bookings per month and ...


2

If you quote the following sentence also, you have the answer: Events do not travel, they just occur. However, the term event is often used metonymically to denote the notification message itself, which may lead to some confusion. From the context it is clear that the two other quotes are talking about the event notification message rather than the ...


0

Rather than attempting to answer the entire question, let me offer a concrete way to share data: just use any mechanism (jQuery, ajax) available in your implementation language that lets you call your webserver. Use a GET call to get constant data with automatic caching. Use a POST/PUT calls to get/set variable data. You can use other request methods, too, ...


0

Consider this alternative, which limits the scope of important_var to a single source file and also encapsulates all the important behavior into a c-style class. important_class.c static float important_var = 0.0; void do_important_operation(void) { math.operation(important_var); } void do_important_adjustment(float amount) { important_var += ...


1

Would it make sense to create an interface for each handler to provide access only the settings that are of handler's concern I would generally say yes. If each object takes a generic config then that makes life very easy for you (the programmer), but the user/client is only going to discover missing configuration during runtime. I would rather have the ...


5

The smaller the objects the more difficult to visualise program flow is. But the problem here is not that you have objects, its that you're trying to create a program from objects in a procedural manner. Your objects should be completely self-contained black boxes to the calling code, if you can make them like that then you can start to use them without ...


3

It's very typical to use the domain model as the resources in the web API layer, but it's usually not the right thing to do. The domain layer has clients, including the web API. The web API has clients, including your UI. The needs and wants of domain clients are not the same as the needs and wants of web API clients. Write your web API for your clients. If ...


1

One common approach is having a Java container server like Apache Tomcat. You must program the business logic in Java Servlets or Java Server Pages. Tomcat can also serve html files.


1

I'd start by checking out simple Java servlets. They provide a relatively straightforward means to implement HTTP methods at the server side. More complex frameworks exist, but they'll sit on top of the standard servlet framework. e.g. here's a simple servlet method to return a web page upon request public void doGet(HttpServletRequest request, ...


2

In addition to the other answers, there's another benefit to making these functions private and testing them via the public interface. If you gather code coverage metrics on your code, it becomes easier to tell when a function is no longer being used. But, if you make all of these functions public, and make unit tests for them, then they will always have ...


0

You do not need to declare the methods public just to Unit-test them. Unit test normally should belong to the same package where the class under testing belongs (of course, inside the different source code folder). As a result, also package private and protected methods can be accessed for testing. See Maven layout, for instance. While it may not be worth ...


3

I think you might benefit from a slight shift in the way you view unit tests. Instead of thinking about them as a way to guarantee that all your code is working, think of them as a way to guarantee that your public interface does what you claim it does. In other words, don't worry about testing the internals at all - write unit tests that prove that when ...



Top 50 recent answers are included