instruction
stringlengths
34
36.1k
For a safety-critical domain, with a code standard including the MISRA C 2004 guidelines, a "simple" piece of code becomes obtuse, chiefly because of the requirements both that all if() statements have an else and that there is only 1 return per function, and 1 break per loop. The original code looked like this: while ...
There will be 4 roles, with 3 roles having a same use-case that is called view campaign and a use-case view segment. Can we put a same use-case more than one time in the same use case diagram? The idea is, in the same use case diagram, 3 view campaign use-case for the same system.
Let's assume we have an Entity { "id": 1 "inProgress": true, } We have endpoints: /api/v1/entities/ for fetching all entities, /api/v1/entities/1 for fetching entity with id = 1 /api/v1/entities/in-progress for fetching entity which is in progress. Note that there can be only one entity in progress. Now, we ...
Why should I decouple an authentication server from a gateway in a micro services architecture ? A clear drawback is the additional network load needed to query the auth server in each request. Are there any clear benefits to justify this cost?
I am in the process of migrating a pretty much monolithic PHP application to microservices. With the development pipeline, docker containerisation, CI/CD and scalability in mind, what would be the best practices for designing and deploying the following, which I think is a pretty common scenario: Our service has a publ...
I am a C developer for an embedded system. YouTube has recently started recommending "C++ for embedded systems" talks. Having watched some of them, they pique my interest, but none of them answer the question they leave me with. These talks (especially Modern C++ in Embedded Systems by Michael Caisse) advocate for a de...
It seems that some components like to pass an event as the first (or only) argument for a change event, eg (the native input, Material-UI's TextField) and then the programmer accesses the value with event.target.value, while other components will pass the value itself as the first arguement (eg. react-date-picker). Her...
I'm a newbie. Please give me a detailed (very detailed one) about these two types of programming that even I, a beginner, could understand. Their core differences, relevant things that I must remember, things like that will be helpful.
I'm using Azure DevOps Pipeline for CI and CD (Continuous Integration and Continuous Deployment). I realize there are many ways to define de build Pipeline. Let me explain with examples: For one of my project I started by creating 2 Pipelines. Both targeting the same repository, same solution but one for Desktop build ...
Here are the design considerations for a software. The querying of data should be as fast as possible (reader <1s, writer <2.5s possibly since it also take time to reach the client end web or mobile) It should use microservices so there can be a swarm of them when load increases The system writes should be efficient ...
I've read that generally it's easier to write an interpreter than a compiler. If that's true, what's the reason? Writing an interpreter seems to me equivalent in the level of difficulty as writing a compiler, provided that the compiler simply translates the code to another high-level language (like c), and then uses an...
I have a stream of data recordStream that I am collecting into a Map. Using a chain like this. recordStream .filter(Objects::nonNull) .map(RoomSchedule::new) .map(roomSchedule -> roomSchedule.flipIfNeeded(processingDate)) .filter(roomSchedule -> roomSchedule.shouldBeConsidered(proce...
Let's say I have a function like this: /* Mode is a bool that determines whether the function uses it's recursive mode or not */ public static int func(int n, boolean mode) { if (!mode) someCalculation(); else func(anotherCalculation(), mode); } That is to say, depending on what mode is, the same function dec...
I don't exactly know how to phrase the thing I'm searching for in a succinct way, which also made it hard to research. In my application I need a random list of booleans, say of length five. The number of True's and False's in the list are fixed, for example 2x True and 3x False. Generating a list of that kind is easy:...
I need to test whether data returned from a search is correct. Several operators can be used for search (term, prefix, wildcard etc.), several fields can be searched (firstName, lastName, email, address etc.), and of course any search word (''John'', ''Smith'', ''john.smith@gmail.com'') can be entered. Thus I have ende...
I'm trying to make a browser MMO game as a hobby project. Currently, the server-side code is written in ASP.NET Core (this was not my choice; the game started as an academic project and the prof imposed C#), while browser-facing client-side code is written in (almost) vanilla JS¹. While writing JS code I was sadly payi...
I have a class that could: Have multiple types of containers Have multiple types of implementations and what I did to model so far is: public interface ChildClass { Container getContainer(); ... } and one of its impl (have a total of two, could be extended though): public class ChildImplA implements ChildCl...
I understand what pure functions are and when someone says pure functions are composable - I believe it means that the output of one function can be passed as an input to another function but same thing goes with impure functions as well, doesn't it? Take the two functions below: int sum(int a, int b) { print("sum"...
I am building a class diagram where "Interface A" is implemented by a member of "Class B". I don't know if I should even be drawing a relationship between these or if I should, what would the line look like? EDIT: To give a little more context I'll give a small example of what I'm talking about (downvotes without expl...
We have one project and separate teams which work on separate modules. What we need is a strategy that allows our teams to work on one project but without access to each other source codes. one project multiple teams (separate) each team doesn't have access to other's source code ability to merge repositories (or any ...
How is it done in practice to maintain a project documentation but not the documentation to the users but the doc for the maintainers. For example, is it customary to just look at the files and understand how it works or we should have class diagrams, etc to explain the project? I don't see any project on Github having...
Currently I am developing an embedded system, running multiple tasks within an RTOS on a heavily constrained (mainly memory-wise) system. My team-lead advised the use of dynamic memory allocation. However, safety-critical standards like MISRA C advise against it. So what are the sensible alternatives? Creating shared m...
I have programmed a Java Swing application. I have some bugs in my program and I want to discover where in the code these errors occurs. With normal code (Non-GUI related code) I apply debugging for such type of wishes. My question is how to debug or profiling (or any other technique that will help me) a Swing applic...
Say I have an MD5 hash. I need to decrypt. I also have a wordlist of 100.000 words, in an array. I KNOW that the MD5 hash consists of 3 different words, all present in the array. I dont know which three words, and I dont know the order of the three words. The array is in alphabetic order. All I know for sure is, that t...
I have a software accepting a HTTP request like this (and I'm happy with that): /products?page=2 /products?category=123&page=1 /product?id=123 /cart?show=table Now there is a consumer third-party plug-in, I want to use, requesting like: /products/page/2/category/123 Where is the right place to integrate this? In the...
I have a project that does some Dijkstra searches on a graph, I implemented a red-black tree and priority queue that I use for the nodes, however I also need the same data structures for other things such as edges. I think there will only be 2, maybe 3 types of struct I would use it with. In such a scenario where the s...
What is the proper way of combining session-based authentication with stateless, token-based authentication for a REST API? Use case: User logs-in in the standard, traditional, session-based way. Most of the website uses this login flow. On one of the pages, a JavaScript script wants to request some data from a RESTfu...
I am looking for a simple software architecture that is able to evaluate user data using different versions of algorithms. According to my concept, the user is able to upload tabular data via a Web UI. These are stored in a PostgreSQL server. Another user role "developer" uploads (trusted) R-scripts or Python-scripts ...
I am developing an C++ application, which creates tree like structures (collections) of strings. I want to add the ability to save the information of these tree structures remotely/locally (can be text files) and together have version control function. In other words, I want to save and version control the tree structu...
I'm writing a GUI application which needs the facility for users to interact with the system and execute tasks via a sort of command line interface. The user will type commands in a text box, with the following format: [Command-name] [Param-name] [Value] Where any number of Param-names and Values can be written after ...
I'm working on a system where users have different types of 'Accounts' of the financial type. I'm struggling to come up with a design that works. Background A user has 2 types of accounts: A 'tab' account and a 'debt' account. Debt Here, the 'head office' pays for things for the user. Things like an event, a dinner,.. ...
So you open up file explorer on your computer and can create folders, add files, rename, etc. I'm doing the same thing in a web application that interacts with the file system on the server. I'm somewhat early on in the project and I'm concerned about my approach on the folder structure. Right now, I'm using a guid t...
Lets say we have an API that receives requests to commit a money transaction. The API receives the requests from a certain client and calls for a certain 3rd party service (lets say provided by the bank - call it bank service) to commit the transaction. We choose to implement the API in a way that all of its endpoints ...
Most programmers (including me) believe that methods with a boolean flag parameter should be refactored into two methods without the flag parameter. Are there any use cases for a boolean parameter where it isn't a flag? I haven't been able to think of any. However, just because I can't think of an example doesn't mean ...
I am currently working on problem with a chicken or egg first situation. Basically, I am designing a solution which goes like this: World is a collection of countries; Each Country has a name, flag and president (all are strings); There will be relations between countries, like country A is friend or supporter of coun...
Although I have seen a few Bootstrap sites, I have only just started to look into it seriously and I was quite shocked by what I saw in the HTML - loads of nested divs with multiple classes attached to each. In the old days before CSS, people used to decorate their HTML with fonts, colours, etc., and this was considere...
Let us say I have some data in a Json format. Let us say the Json format is the following: {title, resources[] } The resources array contains information about a graph. But it should be iterated upon and converted to a different format. The problem Given the resources array size is 100, it should be fine and reasona...
I commonly come across the terms "package" and "component" in software engineering. To my understanding, both indicates an independent software that can be used by another (larger) software. What are the technical definitions of "package" and "component" and what are the difference between them?
I have Handler classes which accepts Queries and returns Results. Handlers is anemic. They accept input data bag and returns output data bag. Handlers can be many so I created common generic interface for handlers and common interfaces for query bags and result bags. Additionally, I created HandlerManager class, which ...
My system looks the following: I have N message producers, N RabbitMQ instances, N message consumers and 1 service. Producers produce the same messages while consumers consume the same messages. Here is the problem. Consumers must agree on who calls the service API, since calling the service API twice with the same me...
We have a Single-Page (SPA) Ajax-based Java Spring/Hibernate app running in Tomcat 8.5. The app's performance is acceptable, but not lightning-fast. A typical Insert Record takes 3-4 sec., e.g. 05 Nov 2019 14:55:41,686 INFO Insert Start ... 05 Nov 2019 14:55:45,766 INFO Insert End We have all the standard stuff, lik...
Assuming you have a software which you gave to clients. Now we all know that exceptions can be saved to files, databases, and so on for tracing errors by technicians. As all engineers know, no Apps in first releases will be bug-less, but it must have bugs for either logical or randomly unknown reasons, such as [Hard di...
Became tech lead of a startup a few months ago. Software development is under Product in the org chart. Even by startup standards the codebase I've inherited is poor. Example: the dev team took three weeks to update static text in the footer of the site and even then they gave up after 80% of the pages. Updating the fo...
Our application needs to run in a locked-down operating system. Due to quality and regulatory concerns, all updates shall be prevented or blocked. Therefore, our deployment includes the pre-configured operating system. To make any changes to the OS, admin credentials need to be used. Some teammates think the "updates b...
Michael Nygard writes in Release It!: Have you ever checked in a commit that had bunch of new files like "Foo", "FooController", "FooFragment", "FooMapper", "FooDTO", and so on? That is evidence of bad layering. This sounds pretty significant as almost every code base I saw so far looks exactly like this. For example...
I am getting confused on how exactly should I be using exception handling inside a class that respects S-Principle. For example consider this code in C#: public class BcryptDecrypt { private string _password; private string _hash; public BcryptDecrypt(string password, string hash) { this....
Let's assume we have a class structure for a particular application (a University manager for example, with classes representing semesters, subjects, timetables and so forth). It is to be a desktop application (WinForms for instance), with data being held in an Sqlite database backend. The schema for this database is b...
There are TDD automation scripts ready and running. TDD tests are written in granular level(class, functions, module) and BDD is written in Behavior level. Is it feasible convert this TDD script to BDD ? Or the question makes no sense ?
In development I have a Java backend API which I'm running with Tomcat. I'm wanting to wrap the backend in a docker container and deploy to an AWS EC2 instance, and be able to scale up/down. Does every docker container need to have a separate Tomcat server running? I don't know any way around it, but I guess it just s...
I'm new to micro service architecture and I'm looking to understand how services should/can interact with each other. The acceptance for my current story requires me to: Email a document Backup the document emailed Persist related information to the backup My client is an existing monolith project that we developed...
There is a C++ project. It is supposed to be executed on x86 CPU, target OS are Ubuntu 18.04 and Red Hat 7.4. There is an idea that there is almost no need to install anything project specific on a build server because all dependancies the project has are stored inside SDK folder. It includes compilers, libraries, requ...
Given a series of points, I need to assert that the plotted points form an arc (with a certain level of confidence), and I need to approximate the radius of the arc. For example, the following points : [ [337,401], [333,395], [330,392], [327,391], [324,390], [322,389], [319,389], [317,390], [314,391], [312,392], [3...
Having the following classes: Person.cs namespace Project.Domain { public class Person { public int Id { get; set; } public string Name { get; set; } public decimal Money { get; set; } public decimal CreditScore { get; set; } public Person() { Mone...
Imagine a typical HTTP service that does async db queries. If HTTP requests are received more quickly than the db can complete queries (such as because the db disk or network is slow), the Promises will accumulate in the event loop and presumably cause memory pressure, trigger swap-hang etc. I would rather the HTTP ser...
I am learning MVC design pattern as an android developer and I've been seeing that it facilitates the testability of code. I understood this concept, but in real case I'm frustrated. Can someone please explain how this is achieved in a real example?
I have a code that is reused for multiple projects. I'm having hard time to maintain across all branches. What's the strategy to maintain all of my branches? Say if I have a base code in one branch, how do I sync to all of my branches whenever I push to the base code? The features is not always the same, but most of th...
The project I'm currently working on a Spring Boot project, and I have a question regarding testing against the database. Our testing tech is currently JUnit 4, Mockito and DbUnit, and we test queries against an in-memory H2-database using JdbcTemplates. The project is barely 2 months old, and we already have between 3...
I am trying to model a robot controller I am working on. If I would think in Object-oriented design, I would come up with a component diagram like this : However, we use a data-oriented framework (ROS/Orocos), so components are linked together with "ports". In our system, for instance, the WheelsInterface has a output...
If I understand correctly there is no built-in functionality in Git to simply let the program output which version or which commit hash string it is when it is run. Why not? Would it not be a simple feature of git (or any other similar system) to generate a plain-text file in the repository with the latest commit hash ...
We have a POST API that takes data from the Client and send it to different applications (Payment, Email, SMS). We also store all the data sent by the Client in a database for future analytics purposes. We get Bulk vs Transaction requests through our API, my concern is regarding optimizing bulk requests. We can receive...
I have been trying to find this answer but I could not find the proper explanation Some say that they are the same and others say otherwise I know for a compound object, The object will consist of multiple values But for simple objects like int or string can we say that they are identical and values are objects themsel...
This is a conceptual question about applying UML State Machine model for smart contracts in blockchain. I want to develop a smart contract framework in a bitcoin-like blockchain which is based on the state machine concept. It would allow to define state machine events, states and transitions as a smart contract config...
I work in the field of military aviation. The application is a WPF-App within a fighters aircraft and the machine, which runs the app is connected to the internal data bus of the aircraft and also to the radio. All communication from and to external sources is done via the aforementioned devices and all of the data com...
I need to extend the parent classes of two child classes by adding shared methods to them. Starting with the initial definitions of the child classes: class ChildA(ParentA): pass class ChildB(ParentB): pass The parent classes behave similarly but their implementations are different, thus each child class must...
The company I work for wants to move from their current CMS (very expensive and developed and maintained by an external company) to a new one, possibly open source or for a lower price. My colleagues and I are looking at headless CMS and the options on the table, for now, push us to 2 possible solutions: strapi and gra...
I'm working in a real-time project. They are using 3 tier architecture using interfaces but I am not getting how it will work as Dependency injection. I know interfaces can be multiply-inherited and have some theoretical knowledge. I need a brief discussion about how interfaces can be used in a real-time context.
I have a tree data structure where each node has a name, an id, a type and a number of children. Additionally each node has properties based on its type. Thereby each node with type A should only have children of Type B, C, D... and each node of type C should only have children with type D, E, F, etc. Therefore I hav...
I am adding unit tests to some existing code which initially was not tested at all. I have set up my CI system to fail builds where the code coverage percentage is reduced compared to previous build - mainly to set a path of continuing improvement. I then encountered an unexpected and annoying (although mathematically ...
Code design question for Java or Java-like languages (excluding languages which support default values for method parameters such as Javascript flavors): You would like to implement a method with the following features: Take N parameters, for some reasonably large but finite value of N (like N > 2). O(N) of those para...
Not sure this is quite the right question for here, but here goes. Apologies if I'm wrong on that. Summary // In general, is a Plist the best way to store and recall data that will be frequently amended or is it better to store that data in a CSV, Excel, or something else? Context // After much hacking, I have created...
Is there some philosophical reasoning behind why python uses this syntax: for x in range(1,11,3): instead of, for example, the BASIC syntax: for x = 1 to 10 step 3 If Python is supposed to be more human readable than most languages, in this case particular case it seems to be worse than say Sinclair BASIC. I was tryi...
This is a scenario I have seen: I have a shared library with code that fetches data from an api. Let's call this ApiProvider. Currently this ApiProvider is in version 1.1.1 and is currently pointing to the v1 version of my REST api. Then I have to update my ApiProvider to point to my v2 REST api and do some code chan...
A for loop is quite an important part of a programming language so you don't want to spend a lot of time typing it out every time for prototyping. An example of a quite ugly syntax is: for(int x=0;x<100;x++){ I would like to come up with some ideas for a simpler syntax for a new programming fast prototyping language. ...
Assume we want to model a table where players can sit down to get together to play a game (card games, dice games, ...). Assume a few properties associated with each seat class Seat { public int PlayerId { get; set; } public double Money { get; set; } // ... } Say the Table is simply modelled as class Tabl...
Some widely used libraries are still versioned 0.x, which under semantic versioning, means they might break the API at any time. Examples of such libraries: numba v0.46, 1.2 million downloads on conda-forge pandas v0.26, 6.7 million downloads scikit-learn v0.21, 2.1 million downloads There are many popular libraries...
I am implementing a web api and i have crated three layers,data access layer,business layer and presentation layer. In data access layer I have a method which create a user.I use a transaction which contain and a method searchByUsername which check first in the database if a username exists .If not exist then i create...
I publish COM addins for Office via ClickOnce. At the moment, I have only one main branch on the Repos tree (using Azure DevOps), and each time I publish, all the users are automatically updated. Now, what if I release a substantial update - which would involve a change in a work flow - and one of the teams wishes not ...
I wanted to follow up on this previous question I asked related to @Laive comment, but I couldn't think of an excellent way to do so without asking another question, so here we go. With the previous question in context, many users suggested the approach of creating a parameter. The object for a method that has many par...
Currently, in our service layer, we pass an id as well as a new updated value, something akin to updatePersonName(Person person, Name name) which, in turn, calls the corresponding repository functions. Now this works fine if we want to update only a single value. But once we start wanting to update multiple values at...
Use Case Interactor: We can see it in this picture how does a request cross the layers until it reaches the Use Case Interactor. How does the controller pass the request towards the Use Case Interactor? By the request i mean the data from the user ( maybe a form ) I understand that the Input Port is an interface, bu...
Consider this situation: there is a method getFoo(). It now becomes appearent that the method as-is is not useful or even encourages faulty code to be written upon it. A breaking change (e.g. returning a collection instead of a single item) must be made but the name of the method is still fine. Do such changes have a s...
We have a project that is meant to do signal processing. If all we had to do with the software was that one job, we would have a pretty clean architecture. Unfortunately, we've run into an issue most other projects standard enterprise projects don't ever deal with. We need to generate a qualitative scientific analysi...
So I am very new to creating design diagrams. I have a scenario where a user who is an admin of pizza hut selects registration option and the system prompts them to enter customer details. Upon entering the customer details, the system creates a username and password for the customer and notifies the admin that the cu...
In python documentation, I found that every object has a type, identity, and value. Does this mean that the object also contains/stores their memory address?? Or are they just created at some memory location containing/storing the type and its value? To me, the 2nd definition makes more sense although theoretically, w...
I am writing a program that describes different properties on a single Management Company's plot of land. For this program there are 3 overloaded addProperty method's. My question is I can reuse the more general addProperty(Property p) method within the other 2 addProperty methods. public int addProperty(Property p) {...
I have an interface Event and a class Agent. I want to be able to write something like agent.handle(event). However, the classes that implement the event interface will all have different fields and things that the agent.handle method would need to know about, and so I'm struggling between either: A switch on event t...
Suppose I have a set of related types that are returned by a function, treated as a group and have certain shared features. In a classical OOP I would achieve this by having a base class and then implementing each of the related types by subclassing said base class. In Go it would appear the main way of achieving this ...
According to Wikipedia: In mathematics and computing, hexadecimal (also base 16, or hex) is a positional system that represents numbers using a base of 16. Unlike the common way of representing numbers with ten symbols, it uses sixteen distinct symbols, most often the symbols "0"–"9" to represent values zero t...
I've read a lot of useful articles about collaboration with git. Many do's and don'ts, etc. For example, Top ten pull request review mistakes and a nice article about git workflow The Perfect Code Review Process, which is a nice way of doing it. Quite similar to the famous A successful Git branching model. I also reall...
So, I am making a pure 2D shooter in Unity, and I was thinking about cheats a little bit (Yes, I know that nobody is going to play my game but anyway). I was wondering if you can get pressed keys directly from a keyboard (or mouse) and compare it with pressed keys in the OS. For example, I am pressing A on the real k...
What was the rationale for choosing the name self instead of this when defining class methods in Python? Yes, of course, you can name it whatever you want - but the widely agreed-upon name for the first parameter is very clearly self. I ask because there was an article about Robert Dewar explaining why : was added to ...
I'm developing a web application using Spring Boot and React, that needs to return information about hotels from different cities: As an input of the controller, I receive a list of cities that can go up to 50. Additionally, the user can filter the search using many criteria (hotel rate, price, etc.) As an output, I h...
I have some Arabic content that is justified according to western conventions. I justified it because it is justified in ancient sources: However, the way Arabic text justification works is by stretching the cursive words, instead of the whitespace. So what I would like to do is go into the font source, convert it to...
I would like to make an request to all instances of my application. Flow of request is as follow( F5 load balancer -> reverse proxy - apache server -> my application) I do not want to make public ip endpoint on all instances or create service discovery server if it would not be necessary. Are there any simple solutions...
I need to draw a UML Activity diagram for a school java software engineering project I’m required to do. I’m quite new to this and I’m not sure what should be shown and what should not be shown. For this question, I’m interested to show the activity diagram from user input till before the statistics feature produces th...
When I call an API endpoint I have a class to create an object with the response. The object directly maps the endpoint elements so I have all values, with properties, getters, and setters. In my problematic scenario I want to set object(s) for 2 endpoints which both represent the same entity, however one has an additi...
I'm starting a new asp.net mvc core project and for my infrastructure layer I'd like to use WebAPI as this layer should be usable in other solutions besides this one. I'm not really experienced with that and at the moment I'm thinking of having 2 contracts and 2 implementations for them in the infrastructure layer e.g:...
My Business unit has huge number of developers (About 100). Due to various reasons, the developers are nearly solely focused on delivery rather than quality. The bad quality code has already started hurting us. The bugs have become difficult to identify. The code has become fragile. The unit tests are quite disconnecte...
In the "Structure" section of the Iterator design pattern, the book Design Patterns: Elements of Reusable Object-Oriented Software defines the Iterator class with four basic operations: First, Next, IsDone and CurrentItem. In the "Implementation" section, the book contains the following item: Who defines the traversa...
I'm creating a library, and I would like to provide a tutorial on how to use the library. Such a tutorial will contain code snippets as usage examples; therefore, I would like to test these snippets to make sure the code is correct. How can I test examples in the documentation? I'm thinking about some kind of interleav...