instruction
stringlengths
34
36.1k
I'm exploring how I might build a Write Ahead Log. My Use case is for operations like: Log Messages (INFO, DEBUG, etc) File Uploads Where I would write the some information representing the Log Message or a File Upload to the WAL, then attempt flush that message to it's final destination. Effectively what I am after ...
I have an application I am writing on Linux. It is a Java webapp intended to be run on Tomcat. When it initializes, my application will copy some standalone java utility programs to the host filesystem that it will shell out to over the course of its runs. Assume that it is not desireable for me to run these utiliti...
I am creating a board game (such as chess) in Java, where each piece is its own type (like Pawn, Rook etc.). For the GUI part of the application I need an image for each of these pieces. Since doing thinks like rook.image(); violates separation of UI and business logic, I will create a different presenter for each pie...
My question is related to software cost estimation. In Software Engineering, COCOMO I or II, are for investigating cost, effort, deployment of staff and ascertaining an accurate road map of precise time lines of the entire project. COCOMO-II comprises of four sub-models individually addressing the Application Compositi...
My colleague is trying to fetch only needed properties as best practice for avoid unnecessary workload on database side as below. public async Task<IEnumerable<Product>> GetProducts(List<int> ids) { var items = await _context.Products.Where(u => ids.Contains(u.Id)) .Select(u =>...
I read somewhere that it is better to pass an object into the constructor rather than instantiating it in it. So instead of public function __construct() { $this->user = new User(); // more stuff... } I should do public function __construct($user) { $this->user = $user; // more stuff... } But then wha...
I'm currently in a AngularJS/Javascript environment. Currently the application using the polling method (i.e, to retrieve new data from server in a fixed amount of seconds). This is quite taxing and does not retrieve latest result immediately. Assuming the server is using ASMX for webservice functions and if possible,...
I suppose every project that is considered as huge and diversed into a lot of parts (admin side, widgets, API, website with a lot of stuff and management) can finally encounter that it is actually hard to use only one or several entities by some type everywhere. E.g. let's take booking entity in action. We have some ge...
I have a Visual Studio solution with 4 projects, that closely follows the Nop-commerce structure. The following is the structure of my solution. - Core - Data - Services - Web The Web project is an asp.net mvc application. Now I want to add server-side logging to my solution, using log4net. My question is which projec...
I have a php web application that is written with traditional architecture with templating, controllers and ORM models. I also have a nodejs JSON API web service that accepts incoming connections and responds with JSON responses Both Services operate on the same database and provide similar functionality but they diffe...
Just to get any confusion out of the way: I'm starting from the position where I already know what to mock, where and how to do it. I just don't know how to fit the mocking into the TDD process. So let's say I have a my_function() already done and I want to write MyClass() that uses my_function() somewhere. Let's say ...
Given a set of N objects with assigned weights, how would we find the set of K objects that is closest to the average? The average being sum(weights) / N. Also, how could we compute the next set that is 2nd closest to the average, and continue on to the 3rd, 4th, etc.?
SonarQube is a software product which runs various coding style rules and other metrics similar to FxCop or Re-sharper. It defines breaking the style rules as: "MAINTAINABILITY ISSUE This is commonly referred to as technical debt. Issues associated with maintainability are named “code smells” in our products." htt...
Background I am working on a class library in support of a web site. The library combines related APIs from several different vendors, all of which have their own particular nuances and domain objects. As an example, imagine there is a credit card provider that exposes a BankAccount object, a loans provider that expo...
I am designing a .NET tool that is using reflection to report information on methods inside our assemblies. Its completely object oriented and made up of Assembly Objects, Class Objects and Method objects all with my defined information I am retrieving from reflection. An Assembly contains many Classes and a class cont...
I would like to know how I should go about splitting up the work into tasks/stories for developing a web application? I created an in-house organization tool for the company I work at just to make things a bit easier for our day to day operations. It was very rough and ready, I developed it without much planning and ju...
I've seen branching models with a develop and master branch (with features being merged into develop first), where the master branch was always entirely part of the history of develop and would be fast-forwarded after the build runs and all tests pass. And I've seen others where the master branch would contain actual ...
When reviewing code, I normally try to make specific recommendations on how to resolve the issues. But owing to the limited time one can spend for reviewing, this does not always work well. In these cases I find it more efficient if the developer comes up with a solution himself. Today I reviewed some code and found th...
Trying to figure out what is the best practice when session times out so that i can do it right first time around. Assume user logs into a web app and goes to "/events" page, where they stay till token expires after 15 minutes. When it expires and of course notifies the user (e.g. via alert), it would redirect to the l...
I have been working on a project that deals with, let me simplify, Schools and Students. The general requirement is that certain Students could be assigned to certain Schools to work an internship. But the Schools are not only Schools per se, those can be Hospitals, Prisons, Nursing Homes, etc.. Since I'm using an ORM ...
I've got an idea, but I wonder whether somebody else already has named it. I'm writing code to control a machine with actuators, motors, etc., and software will be responsible for preventing collisions between some of its moving parts. It's mostly useful to organize everything as a hierarchy, but collisions are possibl...
I have a use case where I'm asked to read an XML document that is a list of data, break it up into data sub-elements, and transform those sub-elements (in order) into another document format (like a flat file or JSON array). I could solve the problem using a typical synchronous flow, first processing the entire XML d...
I'm reading this excellent series of articles about stream. Can a definition to anti-pattern in the context of java 8 -Stream will be a stream that does not produce a valid result using parrallel and a valid result using sequential calculation? Example from the article: A good pattern: (the stream can be calculated seq...
While trying to debug a weird issue where I knew an exception should have been thrown but was not, I found the following in the Java standard library's java.lang.ClassLoader class: /** * Open for reading, a resource of the specified name from the search path * used to load classes. This method locates the resource t...
If I define an abstract class with abstract members and without any Generalization is a well design in Object Oriented Design?Can I Replace it with an interface?
Short intro: I build an application, using .NET, Entity Framework (EF) as ORM and an SQL Server for persistence. My knowledge of SQL Server goes far beyond simple requests, and I use it to drastically cut on DB operations. Still I prefer to use EF to cut on writing direct SQL when possible. I have an application servic...
In setting up deep linking to android and iOS apps, I've made some use of custom URI schemes, and they work great, especially as a fallback when the mechanism that allows maps from http: fails (as often happens with technology). However, I've noticed one answerer strongly recommend against creating your own url scheme ...
I have a factory that creates products. To do this I need an instance of some other class, that has nothing to do with the actual factory. However all Products should of course use the same instance of it, so I provided that instance to the factory which then passes it to every instance of the Product: public class MyF...
We have legacy code that has unit tests (wohooo :D [is it then still legacy?:D]). The production code is an exe file, another one is a DLL but with only one single entry point exported (for some plugin interface). Then there are separate unit test projects which need to test the exe and the plugin dll. The current appr...
I'm trying to ascertain whether the use of multiple references to the same property is code smell / an anti-pattern, based on the needs of the organisation. As an example, consider: abstract class Person { public string Title { get; set; } public string Forename { get; set; } public string MiddleNames { ge...
I was working in a story and in last minute, I have been asked to hide something from UI and we will used it next release. Should i remove it or comment it Should i remove or comment anything related to this part from code or leave it if it won't effect in anything.
I'm loading a config file. I'm considering the following ways of doing it. Version 1: config = json.load('myconfig.json') config_elm = config.get('some_config_elm') if config_elm is not None: # use config_elm ... vs version 2: config = json.load('myconfig.json') if 'some_config_elm' in config and config['some_conf...
This page advocates composition over inheritance with the following argument (rephrased it in my words): A change in the signature of a method of the superclass (which hasn't been overridden in the subclass) causes additional changes in many places when we use Inheritance. However, when we use Composition, the r...
I believe the existence of this unit test is justified. However, to me, this unit test seems very coupled to the method implementation, though I'm not sure it can be improved upon. class ItemManager { void save(Item item) { if (item.id == null) create(item) else update(item) } } @Test ...
I have some doubts on how to proceed on my project. Two years ago, we started a small project for a industrial quality control (es: dimensional control). Originally the software must ran only in a PC with a printer but, now, it’s runing on six different PC with a DB server. This six application are all different, in so...
I am creating a javascript application that will live in a library and be used on multiple sites. I am looking for it to have the following features and need some guidance on accomplishing these goals: Use an iife to protect the variable scope of my application. use document ready within the iife to ensure dom manipul...
I recently started to dive into CQRS / ES because I might need to apply it at work. It seems very promising in our case, as it would solve a lot of problems. I sketched my rough understanding on how an ES / CQRS app should look like contextualized to a simplified banking use case (withdrawing money). Just to sum up, i...
Say I need to model two use cases: "do something" via a batch file interface and via a web service call (UC1 and UC2). Batch interface will "do something" with each record in the file, while web service "does something" only once. Each UC has different primary actor and slightly different set of input/output data of "d...
I posted a question on SO whether two threads can simultaneously execute a send() and a recv() on the same socket. I was told that while they could, implementing this was an example of a very poor design. My rationale is that packets must be sent every 20ms, so I cannot wait until I receive something before I send anyt...
I am going to create a game that involves decision matrix's like the prisoner's dilemma. Much like the image below, except not necessarily symmetrical, and the values will change with each matrix I generate. I plan to query the data against a decision table to understand what decisions players made depending on the va...
I'm making an application where the front-end can display resources both as themselves or within a modal. Of course, when the server gets a request for a resource in HTML, it's going to include a layout (with a <head>, maybe a header and footer in body, and so on). However, if I want a modal with the resource informati...
There's already a question about How to write good unit tests. Based on the answers provided there, the key properties of a good unit test - Short Readable and conveys intent instantly Independent Fast Repeatable Tests a single piece of behaviour Has a good name Keeping those properties in mind, how would one go abou...
Note: Questions with similar title have been asked before, but please read the full text before claiming that this is a duplicate. Since everybody in OOP uses the terms getter and setter, I would expect they have a well-defined meaning. But what I found are basically two statements that are somewhat contradictory: (A) ...
During the development phase where code can be produced that has been later changed for shifting requirements. Once the project is released and adjustment requirements has slowed we can go back and firm up some of the code that is considerably less than ideal due to the shift of requirements and its adjustments to me...
My company is creating a PDF survey (intended for other companies to complete) and we're trying to make the solution interactive (conditional checklists that become visible based on the status of other selections). However, we're wary of doing anything that a surveyed company's IT department will flag while looking for...
I've been using CMake for years when developing in C++ using Visual Studio. My directory layout has always seen me separate source code directories from build directories. For those who are not convinced of the merits of this approach, there are a few, such as easier versioning (everything that needs to be versioned go...
I have a lot of cases where I need to persist some information into a database and complete a secondary action using third party system. For example I have a trivial case, to save user information and to send an email to the user about this action. How can this be an atomic process ie. how can I be sure that user infor...
I'm developing a software that manages a shop. Anyone can visit the shop as unlogged user (aka visitor). If you want to buy something you have to login first (you become a logged user) and then you can buy). The logger user is child of the unlogged user. How can I describe this situation in a use-case diagram? Here s...
I'm looking for a collection that would suit my scenario: I will be inserting key-value pairs (both integers) of ID and timestamp. The ID must be unique. At some interval I will be checking that collection for "expired" items (as in the timestamp + X < current_timestamp) and will need to both remove the key-value pair...
This question stems from more concrete problem asked here The problem I would like to discuss here seems to be a very common pattern in software engineering. Many applications make use of two-layered architecture - business layer and a UI layer on top of it. I would like to know what is the most clean OOP way of mappin...
I am integrating an ERP with a 3rd party reseller. When we finish processing orders that came from the 3rd party, we send back 2 API calls: Set the status of the order to ReadyToShip whereby we pass shipment information. Set the status of the order to Shipped. I am unsure what the return type of this method should be...
I am a programmer with some experience in building PHP web apps. My latest idea is to build a web app in Laravel which would let driver-users register the route they are going to take when going from one city to another. Each route will be comprised of cities and towns through which the driver will go through/by. Also...
I currently have a single pre-existing Git repo for a client/server solution that contains three subdirectories for 3 sub-projects: /client - An Angular2 SPA application (client-side TypeScript) /dtos - Language-agnostic web-service DTO (data contract) definitions written in T4 /client - T4-generated TypeScript...
I'm new to MVVM, I get the general idea, but there's one thing that I've been having a tough time finding an answer for. Inevitably an application will have a save button in the UI. The UI talks to the View Model, the view model updates the model objects, and then the model saves to whatever persistence medium (DB, F...
For some reason the below design doesn't sit well with me, but I'm unable to come up with an articulate reasoning as to why. I would like your help in forming a case against (or for) it. Say, the design of FooViewModel is as such: // Some Observables Observable_1: bool Observable_2: string; // --- // // The method whe...
When I was starting in OO programming, mostly Symfony and Doctrine ORM, I have been advised at least one time to apply inheritance mapping for a case as follows: For instance, a HR system which deals with job candidates, employees, former employees, part time employees etc.. There would be an entity class User, and sin...
For example, Gitlab indicates that the develop branch is behind master: Example 1 Example 2 One could make a merge request from master to develop, but as there are no code changes it seems impossible to align these branches. The current approach is to remove the develop branch once in a while and to create it again i...
We need to design a database model for an (internal) inventory system with the following criteria: Inventory can hold only 1 type (Item) object. There might be more than a million Item per user. There is absolutely no use case for querying items for multiple users at once. We should be able to query by properties (aga...
I am trying to implement Single Sign On feature(SSO). I have for now three systems that needs this feature. This SSO is relatively new to me, I have done SSO where the domain is same. There browser is no barrier so it works. So with few research i found this good article on auth0.com. https://auth0.com/blog/what-is-an...
In our IT dept we develop multiple systems in parallel, the systems are deployed to different environments, and they talk to each other using SOAP and REST. It's all ASP.NET but we're not in the cloud. I'm trying to find a way of streamlining environments to reduce complexity. Simplified view, let's say there are 3 sys...
As a web developer I have very little understanding of binary data. If I take the sentence "Hello world.", convert it to binary, and store it as binary in an SQL database, it seems like the 1s and 0s would take up more space than the letters. It seems to me like using letters would sort of be like using compression, w...
I wanted to move my program into a class or classes because most of the form post I read say it makes the program easier to read, understand the flow of the code, and improve maintainability. Realizing at some point I would be adding more and more to my code until its over 1000 lines I decided to move my GUI into a cl...
I am very interested to learn the HTTP protocol in depth as well as understand the working of NodeJS streams up-close. I figured out that the best way to do this would be to develop an HTTP server in Node. My question is, as the HTTP protocol itself is based on TCP, would it be possible to use the Node's net module an...
I'm working with an SQL database right now, and this has always made me curious, but Google searches don't turn much up: Why the strict data types? I understand why you'd have a few different data types, for example like how differentiating between binary and plain text data is important. Rather than storing the 1s and...
What is the commonly accepted enterprise standard for Exception management? Consider the project has three layer structure. - Controller - Service throws ServiceException - Dao throws DaoException Is it right way to catch the DAO exception in Service layer and convert them to a Service exception? Again catch the Se...
I developed 2 games in C++ using SDL. Without using any wrappers. I literally loved and enjoyed every part of the journey. Complex algorithms, how 2D works, rendering, audio, input etc. But i am not too good at maths and specially physics. PS: There are drag and drop tools and IDE available for game development, i am ...
This question was inspired by MessagePack, but I'm looking for a general answer about the advantages of in-app vs. external compression. For network I/O, doesn't the transport protocol (at least optionally) provide some sort of compression? If so, what makes in-app compression better? For file storage, what makes in-a...
I've seen Facebook's APIs that will sometimes start with resource id. Also, if the URI is for a business process as opposed to a fine grained resource, would it be acceptable to start the endpoint with an ID, e.g. /{fine-grained-id}/businessProcess So the ID does not represent an item in a list of business processes, ...
I am building a middleware integration that will pull orders from various 3rd party API's and push those orders into our system, as well as synchronize stock and send off shipments. I want to build this in such a way that I can add various retailers later on without having to modify the Core project. I've built this in...
BACKGROUND: I've been developing in PHP for two years - self taught, and beyond the most basic editing, really just a year and a half - but my experience is limited to a small number of environments. For the last three years, aside from random side projects, I've basically spent all my time developing custom solutions ...
I'm writing a toy compiler targeting on x86-64 machines. But I confront several problems when implementing register allocation with linear intermediate representation. I use NASM and GCC to generating executable file. In intermediate representation of the origin code, we assume there are infinite registers(memory is re...
I'm trying to figure out the most efficient way of maintaining a sorted ArrayList. I'm inserting items into the array one at a time. I'm deciding between two methods: inserting the item at the sorted position or inserting the item at the end of the end of the list and using insertion sort to sort the data because of it...
I've got a class Shop which contains a collection of Item objects. You can create a shop in two different ways: Create a shop filled with test data (for debug purposes); Create a shop by reading the data from file I also need to write the shop back to file. There is any pattern that can elegantly wrap this behavior?...
What is the meaning of separating interface from implementation in C++? And also what is implied by interface and implementation?
Let's say that I have an ArrayList of class Person and I have two objects that are generated from two different classes which read and write to this ArrayList. For example, public class Main { public static void main(String[] args) { A a = new A(); B b = new B(); } } What, in your opinion is the ...
I have a simple example of two setups of the same block of code, but i am not sure what would be considered the "better" option, although subjective, i read about methods often doing too much than which they describe. So example is where i want to add data and do a sanity check first... the two choices would be: public...
I'd like to ask what, in your view, would be one preferable and robust software design for implementing continuous processing of records in a time-aware manner. A problem overview of the problem to solve follows: There are records added to the database. Each record is an event with signed up participants. Each event is...
I am learning about device drivers, and based on what I know so far, if your application wants to communicate with some device, it cannot communicate directly with the port that your device is connected to (for example: a serial port). But rather, you should create a device driver that is allowed to communicate with th...
What kind of UML diagrams can describe how a new feature will impact/affect an existing system? For example; my usecase is we have an existing web application (system) that uses framework specific user login & authentication. We need to change the system to use OpenID to login and authenticate users. We also want to d...
In most Java code, I see people declare Java objects like this: Map<String, String> hashMap = new HashMap<>(); instead of: HashMap<String, String> hashMap = new HashMap<>(); How is it possible (i know it is but why) to create instance of a Map interface when we know that we can't create instance of an interface.Pleas...
This is part of the answer about stack and heap in Java: So, why have the stack or the heap at all? For things that leave scope, the stack can be expensive. Consider the code: void foo(String arg) { bar(arg); ... } void bar(String arg) { qux(arg); ... } void qux(String arg) { ... } The paramet...
I am very confused in implementing MCTS for a connect 5 game. According to Wikipedia: Selection: start from root R and select successive child nodes down to a leaf node L. Lets say it's the AI's turn. The current board state is R. There should be no child nodes of R, right? Then, how can you "select successive child ...
At one point or another you might come over functions with a lot of arguments. Sometimes it makes sense to combine some of the arguments into super-arguments. I've often done this with dicts, but now I'm looking at better ways of doing it. I'd like to turn ... def do_something(ax, ay, az, bu, bv, c): # Do something...
For this question, let's assume the following: OOP design principles are being followed. Modules generally do not consume more than one general concern, but different business purposes. Hybrid application (multiple platforms). Covers single business concern. However, this single business concern has several smaller co...
Say I have a device that is connected to the computer through a USB port, and I created an application to communicate with this device. In this application I used the USB driver to communicate with the device. Then later I decided that I don't want my application to communicate directly with the USB driver, so I remove...
Based on what I know so far, if I want to create a driver, and want the driver to send data on some port (for example: serial/parallel/USB), my driver will communicate with the port driver, and the port driver is the one that will access the port directly. Assume that my driver will run in kernel mode. Now my question ...
What is the "simplest" operating system or platform upon which we can do Software Engineering in this day and age? Or, in other words, are there "minimum requirements" for OS & platform for doing Software Engineering? I believe a single-board Linux computer is not too small. I first learned about software engineering ...
I'm a newbie on web development and I've heard about MVC. If I'm right, it's the Controller that take charge of fetching data from DB. So I have a question: In the pattern MVC, how many objects to interface with DB should I use? For example, in my web project, there are two controllers: ControllerA and ControllerB. I h...
Consider (using Visual C++ as an example): cl /EHsc a.cpp b.cpp c.cpp versus cat a.cpp b.cpp c.cpp > unity.cpp cl /EHsc unity.cpp Why is the first variant slower given a modern compiler? I've seen people say that unity builds avoid headers being parsed multiple times. But then why doesn't a modern compiler cache its ...
So here's my dilemma. I've sort of read up on how to design 2-way relationship APIs but I haven't found an answer to my question yet. Say I have 2 entities, one is called 'Event' and the other is called 'Person'. Now, if I want to add a person to an event, I could either choose something like POST events/{event-id}/per...
It is a widely held position that checked exceptions as implemented in Java are a bad idea. If you mark a method as throwing, calling code has to either catch the exception, or be marked as throwing, too. For this reason, it is said that exception specifications are contagious. Consequently, they are being removed f...
Can you made secure, multi-user, client-server application with multiple clients (1-5) directly connecting to database? Or you have to make custom server application and connect them via WCF or something similar? Right now I have connection directly to DB but didn't implemented authorization yet. Using SQL Server Authe...
Disclaimer: I am going to write in Python and in the context of web development with Django, but this question is not language nor framework specific. Let's say I have a PizzaManager class that serves as a utils tool to select pizzas in a Restaurant menu. The pizza manager uses data the restaurant has to perform its di...
I want to make simple authorization & authentification server (with proper audit logging). I used to see on my job or in many examples classic CRUD approach for this purposes. But now I'm thinking about try to use CQRS (+ ES maybe) approach for my simple web-app. But this app requires authorization & authentification (...
I have a rather simple application which consists of an angular frontend and a REST API done in C# For the frontend I use WebStorm and for the backend Visual Studio. Now we need to introduce a new version control and it has been decided to use Team Services (Git). There is no code or any assets shared between the front...
A while ago I was investigating dependency injection frameworks for a project I'm working on in Python (part of a full-time job, moderately large and complex). I found some projects such as dependency_injector that look interesting but many of them look somewhat abandoned. The examples from those projects make dependen...
Whenever I write a piece of functionality from scratch, it's a good and robust code. But often times my assumptions about how the code should work evolve over time. After I reflect those changes in the code, the whole system suddenly loses its quality. It seems to me that the best approach is to drop the old code and ...
I have an Android app which I am refactoring to use MVP. I have an Activity that has two Fragments. Scenario 1 (one presenter): The presenter "knows" each view. So, if one view receives input a presenter method is called and it could call a method of any of the views. Advantage: flexible Disadvantage: the presenter m...
Background I'm working in a team that's looking to implement zero-downtime deployments. We're planning on using a blue/green deployment strategy in order to achieve this. One of the things I'm realising in doing the research is how complicated it becomes to make database changes. A simple operation like renaming a colu...
I am tasked with implementing a web-based gambling system that's operated on site. The requirements given to me by the company co-founder and designer for user login give red flags in regards to security, which surprises me because all of the other roles are required to be secure (cashier, site owner, admin, etc. all h...