instruction
stringlengths
34
36.1k
Context: This is for a library that reads some old games formats representing 3D models. Let's call these low-level formats PRM1, PRM2, PRM3 and PRM4. each of these formats contains the position, origin and primitives of a 3D model they have minor implementation differences but in the end produce the same type of cont...
This is an architectural / design question that just came to my mind when comparing current MVC practices in PHP with component based development in Javascript. My question is: Why doesn't the view (or parts of the view) define what data should be used to display it? It seems to be common practice in MVC Frameworks to...
I've been reading a lot about the singleton pattern and how it's "bad" because it makes the classes using it hard to test so it should be avoided. I've read some articles explaining how the singleton could be replaced with dependency injection, but it seems unnecessarily complex to me. Here's my problem in a bit more d...
I have joined a GitHub project which has many different repositories under one user name. My task is to consolidate these repositories into more logical groupings. Some repositories have dependencies on other repositories using hard coded paths. First, I am wondering how can I determine which repos depend on each other...
I'm curious to know are there any advantages or disadvantages to creating a named binary format as opposed to an unnamed one? I can only think of a increase in the required disk space. Roughly speaking a named binary format is a binary format in which you can identify the data parts by using their name (int, byte). The...
I recently encountered a situation in a Java project where I wrote a block like this: String user = System.getProperty("user.home").toUpperCase(); user = user.substring(user.lastIndexOf(File.separator) + 1); final String path1 = "C:\\first\\path"; final String path2 = "C:\\second\\path"; final Stri...
I want to create a project that can be added as a dependency to other projects in the following languages: Java, C#, Ruby, Python, JavaScript (Node) For example, I want to create a jar which can be added to a Java project, as well as a gem which can be added to a Ruby project, etc. So to write my original project, does...
Here are two ways to answer the following question. I'm trying to confirm what I believe their time complexity to be: If I had a snake game with a x,y matrix of spaces, some of which were occupied the snake, how would I best find an available space to place an apple? I could run through the existing matrix and store a...
What do you think about passing typeless maps to APIs (packages, systems, adapters) outer to Core Domain as in 1st Way below? Strongly-typed objects are inside Domain API, and business rules are using them. 1st WAY: Domain -> Web API -> Clients Passes strongly-typed domain objects Whenever a request comes from th...
I'm designing a new web application which is powered by a REST backend and HTML+JS frontend. There's one POST method on it to change one entity (let's call Config), that has several side effects in the state of many elements of the application. Let's suppose the POST is performed this way: POST /api/config BODY {confi...
Someone told me that speed is most important for them, so they deploy whatever (to production I assume), fix, redeploy/continuous release and so on. I can't remember exactly, but my takeaway impression is that he thinks it's ok to ship buggy code, if you fail-fast etc. Is this a "fail-fast" method and what is a good a...
Let's assume I have access to two rest endpoints, /persons and /products. If I need to retrieve 100K persons with their respective products, what is the best way to do that? How can I join them efficiently ? Implementing temporary table in DB, joining them in memory? For example, If I do it in memory, then I found mys...
Assume that I wish to perform an action on a string (e.g., print the string) if, and only if, the string first passes several tests. The tests are diverse (and may even be complex functions themselves), and "passing" a test may mean different things depending on the specific test. For example, some tests can be discret...
I've been looking into CQRS/MediatR lately. But the more I drill down the less I like it. Perhaps I've misunderstood something/everything. So it starts out awesome by claiming to reducing your controller to this public async Task<ActionResult> Edit(Edit.Query query) { var model = await _mediator.SendAsync(query); ...
I have a tree structure that represents a system of devices that are connected to the PC via serial port. In a way, this structure was inspired by tree model example in Qt and I think that helps to separate logic part from gui. My model has a root node member, and can access all underlying nodes through the root node. ...
I'm looking at the way UUIDs are stored in MySQL. MySQL 8 still doesn't have a UUID data type, and it still doesn't have custom types, so there are two options - store it as a string or as a binary. Binary form saves 30% of space and performs much better, in my experience. Unfortunately binary form is way more problema...
While generating the SamlRequest xml, what should the Issuer element be specified with? In the saml docs (https://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf), Issuer was not mentioned anywhere under the AuthnRequest section. But, If you see the sample AuthnRequest from OneLogin's website - https://deve...
I was watching a lecture/conference speaker talking about reducing redundant code, when going from Service to Model in an Anemic model vs. the Rich model. But regardless of which I use, I end up with similar to same logic in my classes either way. Whether I have: ServiceX.AddName("Johnny"); or Customer.AddName("Johnn...
I'm running into an annoying problem at work, where the domain model doesn't fit nicely into the relational model of our Postgres Database. I have a bunch of primary tables A, B, C, etc. Then there's this other table X, that serves as basically a sub-collection for each of the primary tables. Thus, I want a one-to-many...
Which of these two is the better way of doing the same thing - public void someMethod(String s, boolean bool02){ boolean bool01 = s!=null; if(bool01==bool02){ doSomething(); } } OR public void someMethod(String s, boolean bool02){ List<String> list=new ArrayList<String>(); if(s!=null && bool02){ doSomething(...
I'm currently in the process of writing an API that will interact with a web application, iPhone app, and Android app for my work. The API is pretty simple and deals with pilots and their availability. Since I am creating the API and the client-side applications it seems to me that OAuth2 is overkill for this since I ...
I'm designing an architecture in which I have: public interface IObjectReader{ public Object read(); } public class ConcreteObjectReader implements IObjectReader{ @Override public Object read(){ //do stuff return new Object(); } } Now, if I want to allow a reader to be parameteriz...
To me a stream implies that I should be able to: Put things in one end and receive it from the other end in the same order. Do these things at the same time. i.e. continuously be adding to the top of the stream and reading from the bottom. The problem is that streams only seems to maintain a single pointer which is ...
I'm starting a new project and I'd like to plan it's use with git (using SourceTree) before starting. I work as a self developer and I'm starting a project that will have 3 different areas. This is what is confusing me on what should I do to use git properly. Basically the project will have this structure: Shared: Som...
I was looking at a project recently, which contains the following Visual Studio projects: App.Web App.Core App.Infrastructure The Repository interfaces were contained in the Core project and the Repository classes (implementations) were contained in the Infrastructure project. Why would you put the Infrastructure int...
With a little googling I could find workflows - which automates the business process - to meet some business needs. i.e.; All I could find is it is a piece of software which allows us to split the process into sequence of steps - and allows us to track each step - also helps us in achieving those steps. I could find th...
Imagine this simple PHP class: <?php class MyParent { // this is our common method, we don't use this method anywhere in parent class // but we may or may not use this method in some child classes. protected function helperMethod() { // code } } How is it to have methods like top one in our...
I am working with Java 1.7, IDE is Eclipse Indigo. I have a base class which has id as an int. It also has a boolean variable onlyIdInitialized; I am setting it to true when an object is created with id. public abstract class BaseBO { protected Boolean onlyIdInitialized = null; private int id; public Base...
I have couple of nested resources like Merchant, Hotel, Room. A merchant can have many hotels and similarly a hotel can have many rooms. Right now for managing these resources I doing something like: Create POST api/v1/merchants/11/hotels creates a new hotel. Update PUT api/v1/merchants/11/hotels/42 updates the given h...
I browsed Wikipedia and encountered a new feature of Java 1.9: Reactive streams. Unfortunately, the linked Wikipedia page doesn't help much to understand what those reactive streams are and what's so special in them. It was said they are asynchronous, so apparently there's some kind of buffer. It was also said there's ...
Here are two object makers I made: def make_assassination(i): neighbors = [] def test(graph): for n in graph.neighbors(i): neighbors.append(n) graph.remove_edge(i, n) def reset(graph): for n in neighbors: graph.add_edge(n, i) retur...
Disclaimer: I think about the agile values a lot, and happily support them. After almost 20 years of "non-agile" software development projects, and a couple of years in Scrum and alleged "XP" projects, I'm sorry to say that: the non-agile projects worked out pretty well (they were <= 1000 man-days, small-ish teams, ~3...
I'm building a system using redis as a pub-sub system. I'm thinking about ways to represent multiple groups that clients can subscribe to. I could do this with one channel per group, but this could lead to a vast number of channels on the redis side and multiple subscriptions from each channel. Alternatively, I could p...
Can a use case be both an extension and an inclusion?
I see and work with a lot of software, written by a fairly large group of people. LOTS of times, I see integer type declarations as wrong. Two examples I see most often: creating a regular signed integer when there can be no negative numbers. The second is that often the size of the integer is declared as a full 32 ...
I am developing a server that exposes multiple services to other processes (they could be both servers or hmi clients): those could be hosted on the same machine or not and they could be written in multiple languages (java, c++). I would like an advice to choose the proper protocol (or protocols) to expose the services...
I have seen few projects where access to many system-specific functions was wrapped into the project-specific intermediate layer. Examples included functions for logging (wrapped around Log4J), file IO (methods like write content to the file, catch IOException), resource access, using properties and things the like. Mo...
I had a friend who said: Docker is amazing. You can use it to replicate production and all its quirks on your local machine. Then you can deploy that instance straight through all the staging workflows super-quick. Now this would be true if the developers were writing Ruby, PHP or Go - where there was a direction bin...
Let's say I want to make a webshop, which sells custom mugs (for the sake of simplicity). In the shop, you go through 3 steps: Select cup size Select color Add a logo And then finally it is added to a basket, which then leads to a check out procedure. That means that there, at some point, will be a class Order, which...
I'm currently exploring BDD test frameworks like cucumber and I find it curious when people say since the feature files are in simple natural language it improves clarity and gives a clear vision but, isn't natural language the cause for most of the trouble we have in software Engineering? Natural language is amb...
I've started reading Domain Driven Design. I've got a situation where an Aggregate Root has a child object that needs DB interaction in order to perform it's business logic because one of the constants it uses is saved in the DB. Example: User creates a Customer User creates a Review on that Customer Review might need...
Let's say that I have a custom database contacts, and there are two tables inside: contacts - user - group A user may belong to many group, and a group can have multiple user. If I add/update/remove a user into the database, group should be updated too (if the user belongs to any of the group). How should I implem...
I'm making the transformation from being a web developer whose pages often contain loads of <script> tags to one whose pages contain modular Javascript, encapsulated in functions, etc. I'm trying to work out the best way to handle the situation where the code in a particular script file assumes that another script has ...
I recently got into a slight argument with the other developer on my team about the correct way to develop with SVN and Eclipse. My way of developing in multiple branches is by creating new workspaces for each branch. The reason I create new workspaces for each branch is so that I can separate features/bug fixes from e...
We have a ASP.NET Web API that provides a REST API for our Single Page Application. We use DTOs/POCOs to pass data through this API. The problem is now, that these DTOs are getting bigger over time, so now we want to refactor the DTOs. I am looking for "best practices" how to design a DTO: Currently we have small DTOs ...
Whenever I am using issue tracking on GitHub with my team, should we unassign people from the issue once we close it? I don't know which way should be done, and if there is any advantage to unassigning members.
Our project uses Jacoco for code coverage metrics. Previously, we have checked the line and branch coverage against percentage values. However, the documentation also describes an "Instructions" level, which counts Java byte code instructions. From their documentation: The smallest unit JaCoCo counts are single Java b...
From Zend Docs there is this example of how to use Zend\Di, which is a dependency injection container of Zend Framework: // inside a bootstrap somewhere $di = new Zend\Di\Di(); // inside each controller $movieLister = $di->get('MyMovieApp\MovieLister'); Guidance on how to get $di into your controller is not given in ...
Please see the DDL below: create table Person (ID identity not null, varchar(name), Gender char(1), dateofbirth datetime, primary key (id)) create table PersonOffer (PersonID int not null references Person(ID), OfferID int not null references Offer(ID)) create table Offer (ID identity int not null, description varchar(...
This is probably a sloppy way to see it, but I wonder if the idea of longitudinal datasets (to be used in ggplot2, for instance), can be exlpained as complying with the criteria of data in a 1st normal form. I know the latter comes from the relational database field, but I would see entities within a db that is 1st nor...
Assume I have two different error cases that logically have the same HTTP status code. What's the canonical way of providing data dependent on the error case in the response so that clients can respond differently depending on the error? Today I parse the error message--is there a better way?
I try to understand better what the statement below means on Uncle Bob's TDD Harms Architecture, "As the tests get more specific, the production code gets more generic." Below is my understanding on how to get more generic on production code: Using abstraction for method arguments, and return type, if possible is the...
Working on a side-project writing an API and when it comes to authentication I am a little stuck. I am trying to decide what the differences between using Basic Auth vs $_POST fields for the actual login. Once the login gets posted, I will return a token to the client that will then be used on subsequent API calls. My...
I have a REST endpoint that gets a list of customers in a JSON format. GET /webservice/customers { "count" : 80267 "customers" : [ { "id": 1, "name": "John Doe", "email" : "jdoe@yahoo.com" }, { "id": 2, "name": "Michael Bay", ...
I am currently responsible for reviewing one of my team mate's code for a front end web app. We have established a workflow which involves creating a feature branch in git for each feature we define. Say our app lets you scroll a list of items and click through to the item detail - then the kind of features we have def...
I see some classes in the .net framework that support reading and writing, saving and loading, classes whose main responsibility is not them, for instance the Stream classes and the XML Dom/XLinq classes.
I typically write code that only I use, but I do have a public github with some JS libraries. A key component of most libraries are events. My question may be opinionated, but I don't know where else to post it and it is important to me as a perfectionist. When writing an API do events need to be re-sent through each l...
I recently joined a SaaS company that has so far not been using source control track and maintain their development, instead just separately working on their own portions of a given client's codebase. In an effort to help and positively contribute, I've begun using git on my own contributions and want to bring more (in...
I am reviewing a big C# code base and thought on how to mark it as reviewed when it is, in order to not review it twice. Currently I have a ReviewedAttribute which I use to decorate members that have been reviewed: public class ReviewedAttribute : Attribute { } That approach however, misses an important aspect: How t...
I am trying to understand the broader implications of blockchain apart from the main advantage of immutability. Are there any? It seems like the distributed nature of the ledger can be an asset when it comes to data redundancy but it also seems like performance would be terrible since, as I understand it, all the histo...
I was just trying IDs on the CSS tab and I noticed that a little warning sign appeared "Don't use IDs in selectors" Why does the CSS tap recommend me not to use IDs in selectors?. Is there something wrong about them? (the selector seems to work perfectly). The "{}" code sample says my code is wrong too.
I want to add push notifications to an chat application I am working on. Initially I thought that I should write business logic to detect that a message wasn't delivered and then attempt to send the notification for the unread message. If a user's online presence is detected, I can skip the push notification call. Howe...
In my application, I have to get data from our ERP. For this example, let's say product data. Some of the data will come from the API that our ERP has provided us, whilst some of it will come from direct DB calls as the API doesn't give us all the required detail. For this situation, do I just do with a single Reposito...
When we are developing a software supported by continuous integration (CI), I imagine 3 roles working together: Software developers, adding functionality to the system with merges to the repository. DevOps, maintaining the CI pipeline that supports developers. Testers, working on the "verification" part of CI. My pro...
I am having trouble to understand the following question for my Computer Architecture assignment. Consider a system that has a direct-mapped cache that contains a total of one megabyte; each line contains 64 words. The main memory contains one word per cell. It has a 32-bit address, and contains a total of 8GB. How man...
I have some data in my ERP that is formed in a very odd way (think a HTML field that contains many different fields, formatted in HTML that need to be pulled out using XPath). Is the transformation of this data into the model fields the job of the repository? Or should the repository only deal with getting the records ...
I have a lot of data. Objects with other objects nested like this (JSON): { id: 12, Code: "a code", country: "at", prices: [{ { price: 100, from "2017-05-05", to "2017-06-05" }, { price: 150, from "2017-05-06", to "2017-06-06" }, { price: 200, from "2017-05-07", to "2017-06-07" }, }] }...
I have an abstract class structured somewhat like this: class AbstractQuery(object, zip_code): def execute(self): """ Retrieve information about a zip code The information returned will depend on the subclass """ url, params = self._build_query(zip_code) response = re...
I have to write an windows service in .NET 4.6/C#, which reads messages from RabbitMQ queues and does some processing based on message type. Processing includes reading the message and based on business rules, insert/update SQL database and send out another message confirming the successful processing of the message re...
I'm developing a ML/AI solution and I'm looking to write some unit tests. I end up with large objects with a lot of data. These come from a data source which is built at runtime. The data created as a composition of information retrieved directly from an API - I have mocked that response into a simpler result, but in o...
Presume this situation: Max Number of 256 key slots. Key slots are defined by a struct, and a variable for each (256) has to exist. User defines which keys slots are active at initiation (in my example, I just coded them in). They however will remain constant throughout execution. Program receives input, sends it to s...
I have a table of discounts/offers, which are only applicable when meeting certain requirements. Example: Size: medium, Category: classic, Max. Ingredients: 3, Delivery: collection Meeting these requirements results in the user having the products for a lower price (absolute price, not relative). I am thinking about ...
When a local web server is already running at port 3000, I wonder why the npm module drydock is able to provide data also through port 3000? I thought once a port is used, then other process cannot use this port?
No idea how to write a good title for this question. I'm thinking about introducing an operator in a DSL that makes hidden identifiers (like variables) accessible. Think this.foo in Java or C# to access a member that was hidden by a local foo. Or base.bar when bar is a member in the current class. Let's call this "exp...
What is the difference between so called Traditional Software Development (TSD) and Behavior Driven Development (BDD)? I've seen a lot of different development methods that teach developers to talk in business language. Yet, to me, all of this seems like common sense. How could the developer(s) ever think they could ...
I have now put another rephrased version of original question as requested by the user in the comments with class names mimicking real world scenario of postal office (though I dont know how real world the rephrased example is). Original question had abstract/generalized class names. Also uploaded the correct code for ...
Does anybody face the issue with Design Validation and related overheads? When we deliver a Solution we have a lot of so-called Streams (usually 3-8, average 5). Each Stream is responsible for its functional Module (e.g. Asset Management, CRM, Billing etc.) and prepares Technical Design for it. The issue is that the fu...
I think this is a common design problem, but I keep scratching my head every time I face it. On one side, we have our API which sends or receives simple structures aimed to be consumed by web apps, mobile etc. We could potentially have multiple APIs aimed for different devices. On the other side we have our internal do...
Assume I'm writing a library in Java for performing network calls. I want it to be efficient for cases like highly loaded reverse proxies etc (10s to 100s Krps coming in and out; client requests served in the same DC in under 1 ms; relatively simple processing of results), also, each incoming request might start severa...
We have a list of about 100, 000 customers. Every night, we run a batch search of these customer names against a list of known criminals/suspicious persons. This list contains around 1 million entries. To ameliorate false-negatives, we're using fuzzy string matching which catches small mismatches between the customer n...
Imagine a table T, with 2 columns containing data. Everyday, one row is added the table. Now you add 3rd column to the table (After adding this column too, one row will be added the table everyday). Since the column has been added, its value will be null. So single time executable script is necessary in-order to upd...
Firstly, let me clearly state that I am completely against this, I have real issues with unnecessary, obsolete, untested, shitty code, especially when they end up on a production system. My background is in build and release management/devops and I am now working as a Technical Consultant supporting an outsourced deve...
I'am working on a project that use MySQL as RDBMS. Recently, we have to manipulate a big json data. So, the first solution that comes in mind, and for many reasons, is to cooperate mongoDB with Mysql however it can add complications! (We use Symfony). But from MySQL 5.7, MySQL supports native JSON data type which provi...
I'm Working with php and we using enum's by create an Abstract class that mocking enum behavior - but my question is cross-languages. Where all the helper functions like toString, getEnumTypes, checkValidValue, etc... should be, in a dedicated utility class: EnumUtil or in the AbstractEnum it self (all enums extends A...
I want to add error handling to: var firstVariable = 1; var secondVariable = firstVariable; The below won't compile: try { var firstVariable = 1; } catch {} try { var secondVariable = firstVariable; } catch {} Why is it necessary for a try catch block to affect the scope of variables as other code blocks do? C...
I'm in my first two months as a software engineer and just wanted to get advice on if this can be improved upon. I've created a class that represents data from RFID in the form of a message: class RFIDMessage { string _a; string _b; string _c; string _d; string _e; str...
Following REST principles, I would want to create a GET method for my API that make a search using some criteria and return the results to the client. The problem is that the criteria can have up to 14 parameters, one of them is a list of complex objects, so... I don't even know if it possible to encode/decode these ...
In my workplace, the client is obsessed with line-by-line code reuse. And they use a tool that uses LoC as measure of code re-usability. Often for two modules, if the logic is same as of now, those modules call the same method. Which reduces no. of lines, but seems like a long-term manageability disaster. Are my concer...
I know there are many books on writing clean, modular, readable and whatever else you can say but frankly speaking I find it very hard to remember every advice given on those books. Frankly speaking either you know things or you know nothing at all and find it very difficult to relate to your daily job I think it's so ...
I have an annoying code smell in my asp.net core api that I am passing around, and I can't come up with a way to fix. In an MVC controller action, usually there is a very straight forward logic, at least in my case. Validate model (before calling the action) Query relevant data Do business logic Send response Now in ...
I understand the relationship between an aggregate root and a repository i.e. there should be one repository per aggregate root. What is the relationship between the application service layer and the aggregate root/repository. I assume there should be one application service per aggregate root? Should the application ...
This is not (supposed to be) an opinion question, but it is a newbie question, so if there is just a resource I haven't found that I need to read, point me there :) I am in the design stages of a microservice-based ETL system. One service in particular seems to be a natural candidate for functional programming over oop...
I know that logging is supposed to tell a story about what your users are doing. Eg: User 1 created a thing User 2 deleted a thing User 1 tried to access a thing and encountered an error This is very useful, but what is even more useful is having detailed information about every single HTTP request: HTTP GET /In...
I have a large database of customers. There's a need to identify customers who have two or more customer IDs. This comes mostly from people at the front-desk creating new customers instead of searching for their existing IDs or doing a bad data capture, so we end up having this sort of thing: ID name sur...
NOTE: I am new with the whole concept of state management. I never got into the older languages that "explicitly used" states. I dived into React and Redux for the past week, and as I'm getting into more complicated code, I stumbled across one thing: I now have to sync the UI changes with the Redux state for even the m...
I am writing an implementation of middleware chain in Python. Here is how a middleware function looks like: async def logger(ctx, next): print(f"Started doing stuff with {ctx}") await next() print(f"Finished doing stuff with {ctx}") And this is how you use it: app.use(logger) app.use(some_other_middleware)...
I raised this issue on the github project for RazorJam.Insightly, where as you can see it turns out that an error is occurring because for the particular items that I am retrieving and deserialising from JSON into an object, the ADDRESS_ID value is too large to fit into an int. I initially wanted to submit a change req...
I have two tables: area ( id int PK autoincrement code varchar ) products ( id int PK autoincrement name varchar area_id int PK to AREA ... ) The classes are persisted using eclipselink like this: @Entity class Product { ... private Long id; ... private String name; ... @JoinColumn...
So I decided to created a stack-based virtual machine and the result came out pretty good (in my opinion!). The first iteration was a basic toy VM. I did a rewrite to make the VM work more realistically by giving it byte-oriented memory and data stack as well as n-byte oriented opcodes. After much testing, including a ...
Below are oversimplified examples, but I wonder which route to take what is the best practice when designing API, the simple or the more complex and robust which is better? This looks good and goes along with scala ADT concepts but I fear that it would become overly complex and the clients using my API will a little h...