instruction
stringlengths
34
36.1k
I was wondering about client side vs server side calculations regarding websites that provide some convenience type service. For example, an online website where you input a certain date and the website tells you how many days between today and that date. Or a website that tells you steps to solve the inputted math equ...
I'm dealing with a design problem. Actually I have the following architecture: A Process interface : public interface Processor { void applyNewConfiguration(final Configuration conf); Result process(); } A processor MyProcessor which implements this interface : public class MyProcessor implements Processor {...
So memory segmentation can be done with or without paging. I always hear people talking about stack and heaps when discussing something memory related in C++. However, what I do not get is that if the program's memory (its virtual address space) is segmented using pages, it won't get divided into stack, heap, etc., rig...
I have recently learned C and want to start a project to solidify my knowledge. I've settled on making a very simple text editor, something like vim. The problem I face is that I genuinely have no clue how a text editor even works, and I don't know what to google for to learn about it. Googling about it led to vim's Gi...
I am currently reviewing some of the code of junior developers who just joined my team, I am wondering how should I deliver the output of this review: Should I fix the code myself? Should I give them feedback on the review process and let them do the fixes according to my instructions? And if so, how do I give this fe...
Is it considered bad practice to call for example tshark or ffmpeg in my code, assuming I couldn't find a good enough library to use?
I’m writing an asynchronous, Promise-returning function. In the processing I test some conditions, and if the conditions pass, the promise should be fulfilled (resolved), but if one fails, then the promise should be rejected. I want to know which is the preferred coding style, or which is more readable, when writing pr...
While I do see the benefits of IoC containers (as I've used them a fair bit), I don't see how they can be incorporated within TDD unit tests (note, I'm only interested in unit tests here, not integration tests). When I TDD, I refactor constructors to use IoC, so that I can inject fake dependencies wherever I might need...
Project 1: a Java/Maven project Project 2: a Scala/sbt project Thing: generally, an immutable object instantiated in from 3rd party Java library. For example, ThingBuilder.foo("bar").build() Question: How can I define Thing in only one place, and have it used both in Project 1 and 2? (So the parameters in ThingBuilde...
Is 'call site' some auto code generated by compiler - I come across this term frequently and it sounds like calling method is simply referred as 'call site' - which literally sounds fine but I believe it has some deeper intricacies. And if 'call site' is compiler generated code - under what circumstances this is requir...
I have read this article, but I still really do not know a programming model is. I saw it being used in the following context: Any given instruction set can be implemented in a variety of ways. All ways of implementing a particular instruction set provide the same programming model, and all implementations of that...
Let’s say we have the following abstract class HungryAnimal { private MovementStrategy movementStrategy; public HungryAnimal(MovementStrategy movementStrategy) { this.movementStrategy = movementStrategy; } public void searchFood() { while (/* no food found */) { ... ...
I imagine it is simply, as it is named, the existence of data throughout layers of a software application. I ask because I have not been able to find a clear definition that states something of the sort: Data Persistence is the existence of data throughout layers of a software application. If that exists please share t...
The definition of production seems to contradict what web developers consider an application in production to be. Why is the term in release or published not used instead? I have been in professional web development for ~4 years and we've always used the terminology (development, QA, and production) when referring to t...
I know that the Arithmetic Logic Unit (ALU of a processor performs arithmetic (and bitwise) operations and the result is stored as the ALU's output - but what component, device or software is actually accessing/using the output of an ALU? And is it valid to say that the ALU returns the result of an operations or would ...
For example, consider I have a class for other classes to extend: public class LoginPage { public String userId; public String session; public boolean checkSessionValid() { } } and some subclasses: public class HomePage extends LoginPage { } public class EditInfoPage extends LoginPage { } In fact, ...
I am designing a role playing game. In such games there is a character that has a level. I found out that the level itself is an object. It has values like experience, the knowledge of how moch experience is needed for a level-up, and methods like improve() or gainExperience(). So the character should have a level obje...
So an addressing mode is the way that an operand is specified (from what I understand) and there are different modes provides by different architectures, such as Immediate mode, register indirect mode, etc. In that context, I frequently encounter an a specification of an offset, such as in the direct mode where you sp...
I am facing an issue where I have a data stream that sends unordered data. I'm trying to find a way to receive the data in random order, but send it in order. As an example, I'll receive object4 and then object3 and then object1. I'll need my system to store object4 and object3 when they arrive and immediately send obj...
I'm writing this in node.js I have some data that needs validating before anything can be done with this. The data is validated in two different ways. I can use JSONSchema to validate the structure of the data e.g. the data must contain a name property of minLength 1 and maxLength 100. I then use another validator f...
EDIT I am working on a project to update a legacy ETL infrastructure that supports a number of clients, each with a slightly different setup. Constraints that cannot be changed: Source data can come from flat files over sftp and then to S3, from MSSQL databases, or events published through webhooks. Source data rang...
I have a neat domain model that makes it easy to communicate with an external web service. New requirements have made the external web service's interface messy and now I have to gather data from multiple places in my model. Is a DTO appropriate to hold all the necessary data? I have an interface that deals with searc...
We have three environments: Dev, UAT and Prod. We use TFS to schedule releases of our master branch into Dev for our internal verification, then UAT for business verification, and of course finally to Prod once approved. We've recently adopted a new lightweight Git branching strategy as follows: master is always prod-...
I'm building a REST service in java that does basic CRUD operations on Customers. The easy way would be for me to create one Customer model, and annotate it with JPA annotations so my persistence layer knows how to map it to the DB and add some jackson annotations so that my web layer knows how to deserialize it from h...
Say I have an MVC .net core website where 100% of the controllers/methods are behind [Authorize] attributes (complete with policies and all). Would it be taboo, to carve out a set of un-authorized/anonymous controller/methods to handle user requests for access to the site. It seems perfectly reasonable to me, and outs...
In a multi-tenant deployment of Web application, How can the Asp.Net Core Web API services be designed to work with different authorization services? The Web applications use OAuth and JWT Bearer authentication and pass access token to the Web API services. One approach that I could think of is to, get the Authority ...
OK, so the title is a little clickbaity but seriously I've been on a tell, don't ask (TDA) kick for a while. I like how it encourages methods to be used as messages in true object-oriented fashion. But this has a nagging problem that has been rattling about in my head. I have come to suspect that well-written code can ...
Let's say my app depends on lib A that depends on B that depends on C (we are owners of them all). Now, you bump the version of C to 1.0.1 (a bug fix). How would you propagate the change of C to the app? Would you bump versions of B and A, too? What if there are frequent changes of C needed across the teams? Do you rel...
We're completely remodelling a system at the company for which I am currently working. We're applying DDD and for the very first time I have actually got someone on my team who has some prior experience with DDD as well (yay!) This new system is extremely user-centric, i.e. pretty much every operation within the system...
Using PHP, I created a chatbox, and I used an unorthodox way of storing chat messages in MySQL. The tbl_chat_messages has the following columns: id | sender_id | receiver_id | message | date The actual messages are json_encoded, and is then stored in the message column which has the datatype of Longtext. It is structu...
I have recently come across a design question and will explain it using an imaginary scenario: Assume you need to retrieve the days where there are no bookings for a given date range. You could filter the results and manually identify what date is not contained, but you'd be getting the booking information unnecessari...
I have been working for quite a lot of time on a research project at University focused on Access Control. More specifically, I am studying how to protect unauthorized access to personal data in a distributed system and in general in the Internet. In this context, I stumbled on the XACML (wiki, official spec) specifica...
In the company I work for, I keep seeing IManager interfaces being converted into their real types and lots of "instanceof / TypeOf" if statement checks. For example: IManager manager // passed to method as a parameter if (manager.GetType() == typeof(CustomerManager)) { customerManager = (CustomerManager) manager;...
I am writing a simulation engine consisting of a number of components, each of which operates on a fixed set of shared buffers. In practice, the simulation will run entirely on the GPU. When developing a component however, it is easier to copy the buffers from the GPU, execute the component on the CPU, and write the up...
Recently I have been trying to avoid down-casting object types from an interface type to their concrete types, and 'if' statements that check for an objects concrete type at run-time. This has made me ask myself a question; Why add public methods to concrete classes that also implement an interface? I ended up making a...
We have a bunch of appSettings in our ASP.NET web application, not to mention connection strings, that change on a per-environment basis. Not just for different environments to which the web application is deployed, but across different developer machines too. Therefore, changing these with a Web.config transform isn...
What is an empty method and how are they used? I was reading a documented about the BUILDER Pattern and I got a curious about how it is implemented in C++. The author defines that in C++ could be possible to implement empty methods as default in the builder pattern in order to letting clients override only the operatio...
I don't know if the title is reflecting the question correctly, but I can explain more than write a good title. If I have a database that has (employees, departments, orders, etc...), and have many ways to call the endpoints of this system, and each way requests data less or more of the same entity (e.g employee ent...
In my project I have different types of entities. I get the data for these entities in text files from a 3rd party. I've written a class to read and parse these text files, using the strategy pattern. The method in this class must return different entity types so I've made the entire class generic - something like this...
I work on system with such architecture: There are two types of components, let’s call them CLIENT and SERVER. There is only one instance of CLIENT component and there might be multiple instances of SERVER component. CLIENT uses HTTP interfaces of those SERVERs (they are the same interfaces). What diagram should I us...
I found an interesting quote in my book with which I learn Java: Manche Methoden der in diesem Kapitel beschriebenen Schnittstellen sind in der Dokumentation als optional gekennzeichnet. Bei manchen Collections-Klassen führt die Nutzung solcher Methoden zu einer UnsupportedOperationException . Sie dürfen sich al...
Backstory I am writing a library that accesses the kernel module, uinput which allows you to create or take control of devices in /dev/input/event#, and insert events into them. A simple usecase would allow someone to write a script that would move a mouse cursor to the center of your display, and perform a left click....
When designing a RESTful API, providing a spec for updating an entity will force the designer to make some decisions on how the update will behave (an update mode or type). Here are some of the modes I can think of: If the update body contains null values, ignore them and only update the values with non-null values. ...
I'm creating a software that's supposed to accept a certain form of data and does something to the data. We decided to create a small dependency beforehand which will be used to make the development of the software smoother. We're planning to accept support for json, csv, yaml, and sql files/url's(consuming rest) and c...
First of all, yes I'm aware of PEP8 and the alphabetical method. I do sort my imports first by the PEP8 recommendation: standard library imports related third party imports local application/library specific imports But then, within each category, I like to sort by the length of the module name. Yes, it makes...
We want to pull application and business metrics from the source web application to track billing, usage and performance of the application. These metrics are to be stored in a different database (Oracle) for further processing and analytics. We would be building analytics dashboards over these metrics that would be pr...
We are developing visual controls for WinForms in .NET, and one of our customers using our products is still compiling all his apps for .NET 4 Client Profile. He has to do this as his customers, some larger companies, would not allow the full install of dot net framework since it contained security risks that were unac...
I'm new to this Repository pattern and have seen lot of repository pattern + UoW implementations all over the internet and I'm not able to reach to a conclusion as to which of them is correct . After going through many links I've been able to implement one . Considering the following points in mind It should satisfy ...
I am developing my own header-only library that I want to use as a framework in other software. I am using CMake for setting up demo targets, tests, and so on. However, I am unsure how to deal with dependencies of my library. Currently, I am using the following approach: FIND_PACKAGE( foo ) I have a configuration conf...
What is the best way to inform users that there has been a bug found in some software they used? For example, let's say a user finds a bug in some software and reports it to the development team who decide that fixing this bug will be done in an upcoming release (rather than a one off patch) due to it being low risk (v...
I have a list of 75000 websites that need to be monitored for uptime. Monitoring the websites involves making a HTTP request for the website every minute, and the website is said to be "up" or "down" based on whether we could successfully make a HTTP request and received a HTTP response. This kind of "polling" is the o...
I am about to start coding for a school project that requires me to demonstrate good OO practices in a web app. Now, I have built a few web apps and have never felt the need to define my own classes and utilize objects (outside of classes provided by frameworks and modules) so I was looking for help in making some des...
Once in a while, I leave comments like # We only need to use the following for V4 of the computation. # See APIPROJ-14 for details. or # We only need to use the following for V4 of the computation. # See https://theboringcompany.atlassian.net/browse/DIGIT-827 for details. My main concern with doing so is that it inc...
I have data that is structured like the following: users: id | name | parent_id 1 | Bob | NULL 2 | Jan | 1 3 | Mat | 2 4 | Irene | 2 5 | Ellie | 2 6 | Laura | 5 7 | Uma | 6 user_sales: user_id | sales_period | total_volume | total_revenue | .... 1 | Jan-2017 | 1000 | 56000 1 ...
I am writing some code to parse some files (which I call "assets"), and I'm planning to structure this as three classes: AssetParser, NamespacesParser, and TransfomersParser. AssetParser will use objects of the other two classes to parse some parts of the assets. I want to write this as three classes rather than one bi...
https://www.toyota.de/automobile/corolla/index.json I understand how .JSON works but, how is it possible to use that instead of say, .php or .html this is the first time I've seen anything like that.
We currently have a Users table in the database, this has quite a few columns in it. Around 50% of the columns are barely used in the system (only on one or two pages). We've been discussing amongst ourselves whether to split this table into two tables e.g. Users and UserSettings. Our thinking is also that we could the...
Sometimes it is pretty easy to find very natural concept to represent relationship, for example Person and Team can be connected by Membership, but occasionally it is not so easy and the concept might seem like so artificial. So is there any strategy to find or name these kind of relationships?
ISAs define things like instruction lengths and the instructions themselves and there are some things that I do not understand. Does the instruction length (the amount of bits) affect the amount of instructions that can be performed in a clock cycle? I have tried to do some research on what really determines the amou...
I'm trying to figure out how to create a Node.js/Express.js application that is a framework for hosting and running third-party code in my application, and what are the appropriate JavaScript/Node/Express terms for these concepts if they're different from other language I've used in the past (C++/C#/Java). In developin...
I'm currently working on getting a good workflow going on, from development to a kubernetes deployment on cloud platform. I'm pretty comfortable with various docker commands, but rewriting long commands each time is getting painful. For example, for deploying docker images to google cloud I need to tag and push them ...
I would like to write a data structure implementation in Java that uses caches as a core part of its functionality, and I would like the user to be able to provide their own cache implementations that implement a particular cache interface so they can test performance using various strategies (like LRU, LFU, MRU, etc.)...
I work in a company that uses microservices. We have one particular service (let's call it Cart Service for example purposes) that manages some logic (storing carts, allowing other services to add and remove items from a given user's cart, etc). My team owns this service and multiple other critical paths (like Item Sea...
I understand how service prividers in Laravel works and how to use them. But I'm not sure about how to keep clean code, specificaly in count of method parameters. For example I have this route: Route::post('/user/user-rooms', '\Modules\Administration\User\Services\UserRooms@rooms') Where class looks like this: public ...
Suppose that I have two services Person Service and Company Service and I want to maintain links between them for example a Person is linked to Company because he works there or he owns the company etc. So I will go ahead and create a database table like PersonId, CompanyId, RelationType Now the business logic can be...
A system that sometimes will need to use a pretrained machine learning model. That model is about 10Gb on disk, and when loaded uses about 10Gb of RAM. Loading it from disk takes a nontrivial amount of time, so in general I wish to not do it too often. Certainly not every function call against it. Right now, I am using...
We have a database with stores Outlets / Supermarkets (mainly in germany but other countries are also possible). We store some informations of this outlets / supermarkets like name, street, postalcode, city, geocodes (longitude , latitude). It is very important that one outlet is only once in the database. From our c...
I got an architectural problem here. Let say there is an IShell. It mainly responsible to map user's commands (represented as a linux-like strings) to an appropriate IExecutable's. Those executables are pretty various. Hence, there are different modules/assemblies/dlls (or how-the-hell-you-call-it): Module1, Module2, ...
Please see the code below: public sealed class UKCurrency : ICurrency { private static readonly int _decimalPlaces=2; private static readonly decimal[] _denominations = new decimal[] { 50.00M, 20.00M, 10.00M, 5.00M, 2.00M, 1.00M, 0.50M, 0.2...
I have dozens of Delphi (version 10.2.2 Tokyo) functions that I would like to be accessible from a C# MVC web project. These functions are mainly report queries that take a bunch of input parameters and output an array (or list) of records (or objects) as result. I have full control on both code bases, Delphi and C#. W...
Note: BLL = Business Logic Layer (can also mean your domain) I'm trying to understand the onion architecture. It seems to me that it's actually the same thing as the layered architecture, only with the dependency inversion principle (DIP) applied. For example, this is the typical layered architecture (arrows represent ...
I am working on EWS. A class is made to query mail box and read emails. public class MailReader { private readonly ExchangeService _service; private readonly PropertySet _propertySet; private readonly IFolderSearch _folder; private readonly IMailAttachmentAdapter _attachment; private const int ...
We currently have a work stream where we are splitting out a Monolith into microservices and there has been a debate as to how we will access and persist data. To give you a good idea of how most of our apps are being set up, we have an app built strictly for the UI, a Web API it talks to and then another Web API that...
I have a set of objects with different attributes; e.g. a set of cars with colors, brand etc. I choose subsets by virtue of a specific set of attributes. Now I want to identify pairs of such subsets that differ only by one element. Eg. say I have 4 cars: A: Red, Ford B: Red, Ford C: Blue, Ford D: Green, Volvo Then the...
Should I leave the else clause in a case like this where the compiler marks the else as redundant code and the else makes the code appear more logical --> better readable? if (aCondition){ doStuff(); return someMethodResult(); } else { doOtherStuff(); return someOtherMethodResult(); } or if (aCondition...
I've got a view that renders a menu. These menu items are dynamic, in that they only appear based on some conditions (authorization, for example). I have two options: Hard code the menu in the view with all the necessary conditionals Structure and filter data outside of the view so the view is only responsible for dis...
I'm working on a display library which in most cases works on a 2D plane but it has some components which display 2D projections of a 3D space. This domain has the notion of Position, Size, Position3D and Size3D. Position and Size are straightforward: data class Position(val x: Int, val y: Int) data class Size(val wid...
I often see the term stale used to refer to data that is out of date, and fresh to describe data that is up to date. Both of those make sense to me. But what do you call data that is not yet fresh, and has never been fresh? The situation that made me ask this question is I'm working on an application that uses an ORM, ...
We have a dependency to a third-party service which exposes a gigantic interface of which we only need like 3 methods. Additionally, the interface changes frequently... I've decided to wrap the interface in a class in our project and only expose the methods that we need. But I'm unsure how I should handle the return va...
Let's say my user requests my ES/CQRS system to open a support ticket: The controller sends an ask-support command, this command checks if the user has enough credit to do that, then emits an asked-support event. Somewhere, a listener responsible for side-effects gets this event. It calls an external support API to op...
where I currently work, there is a team that uses code-generation to generate slight variations of a program. I find this a little bit awkward. I can imagine using code generators that produce complex code for stuff that is usable in different projects, but using a code generator just for variations of an existing prog...
I've been struggling with this issue for a while. Let's say you have a business application that has a rich domain and in one of the front-end views you show a list of open Orders. In this view you show things like that orderDate, customerName, totalAmount,... but the client also wants to see how many items are in the ...
I've lately been involved with WPF and looked into MVVM. I understand that view model shouldn't be aware of view. However, sometimes I come across situation where my initial instinct is to write property in view model something like public bool ShowDialog { get; private set; } or public bool ShowPopUp { get; private se...
Context In Clean Code, page 35, it says This implies that the blocks within if statements, else statements, while statements, and so on should be one line long. Probably that line should be a function call. Not only does this keep the enclosing function small, but it also adds documentary value because the fu...
I've encountered API that tell as being "restful" but then I see resources with verbs instead of reserving those said verbs to the METHOD. Here's some (paths shortened so only the relevant method and path parts are shown): POST /things/84/lock POST /things/84/unlock POST /things/84/edit POST /things/prepend (Adding to...
I do a lot of coding in python and got a lot of if conditions without an else statement so to say partial branches. E.g.: # if a certain kwarg was passed to a function call if kwargs.get('a_option'): # overwrite an entry in an already existing dict: config['a_option'] = kwargs['a_option'] This always shows up ...
I've created about a dozen services for a intranet. Now I've gotten to the point that these services are more coupled to each other than I'm comfortable with, and I've been having problems where once service can cause a few other service to degrade. I've been working on a EDA design so that I can make these services d...
I'm currently teaching myself event sourcing and have got the concept enough to start developing a dummy app in C# and EventStore. My app is an easy-to-understand bank account system. If we model a bank account as a series of withdrawal and deposit events then we can easily calculate the account's current balance by ad...
I'm meeting quite a challenge. We have an old grown software with mostly Delphi applications, and an underlying ISAM database server (ADS)1, used with a lot of free tables and manually programmed referencial integrity (if so at all). Our deadline to move that mess to a modern RDBMS is 2020. Some of the preferable DB Se...
For many languages there are various tools which measure code coverage. But how exactly does this work? I have some ideas, how this could work: Do coverage tools just run the code in the debugger and step through it? Is some kind of static analysis used? Or do some tools just inject some markers into the source code,...
I'm reading Applying UML and Patterns and trying to match the OOA&D principles in there to a project I've worked on. It is kind of a retroactive learning exercise. The basic question I'm trying to answer is do I have the correct understanding of how to find the actors in this domain? Have I found them correctly? The pr...
I need to make a web app which provides the feature to install/uninstall plugins. Think of something like Eclipse IDE like software. The only difference is you cannot restart it like Eclipse to apply changes. I guess I can say, it would be similar to Wordpress. I thought of am implementing this using OSGi as follows: W...
This article states However, this design does run into problems with some of the methods of the MutableSequence ABC. Most notably, insert and __ delitem __ can't operate on position 0, because you can't change the head of the list when the only reference you have is to the head of the list. If we have a reference...
I've been looking at ways to let my app's users write plugins for it. However, to give them more options, I decided to implement a polyglot plugin system. From the engineering perspective there are multiple ways to do this. Transpiling: Not many libraries that can reliably do this. Bindings: Types can be a pain. Usin...
Let's say I have a mobile client for answering questions and then purchasing a widget. For example, I might have 10 screens from my UI with about 8 questions per screen. Imagine there is a screen for first name, last name data, 'create personal information' is basically the operation/service call. With REST, JSON ov...
I have seen this pattern that allows web pages to interact with local system resources through a HTTP interface and I have a couple questions about it: What is this pattern called? What recommendations exist for implementing this pattern? What are the security implications? Basically, the requirement is to access a l...
So in networking class they taught us the OSI model, TCP, CDMA, congestion, frames, etc. What I would like to know if standards that have been around for 20-30 years like TCP, are burnt into today's hardware, or can someone come up with say TCPX, write the code, deploy it to two machines on the network and use that pro...
Who writes functional specification in a software company ? Given a software company typically comprises of Software Engineers, Engineering Managers, Product managers and Directors?
I want to implement the "shopping cart" feature on my website. Both anonymous/unauthenticated and authenticated can have it. While it's clear how to implement it for an authenticated user, it's not completely clear for the anonymous/unauthenticated user case. I believe that I'll have to create a long id, such as GUID ...
Speaking of php. It doesn't really have its own runtime in compare to python, ruby or go. Php is jsut a text preprocessor. What exactly does it mean by, Php doesn't have runtime?