instruction
stringlengths
34
36.1k
While working on an application, I am facing an issue. And I am not sure how to solve this. For explanation I have managed to come up with a simple example below: Consider a Grocery Store application. It has a finite number(which means the items wont change often) of items. Each item is different than other a...
So we have a microservices architecture. Quite often we release features that require changes in several repos simultaneously. What approaches are best for handling this? Ex. Pull Request 1 from Service A dependends on Pull Request 2 from Service B. How do we make sure Pull Requests are integrated and merged into the s...
I'm doing an assignment in my Linux class and my teacher is a fill-in so he's just going with what is given to him. In the assignment it says to write a script using an Implicit loop to create file systems on partitions (they are the arguments) and use an Explicit loop to create a mount point under /mnt. No where in...
I'm refactoring a project I did for my work and I'm trying to apply the SOLID principles to make the architecture cleaner. I've run into an issue with the Dependency Inversion Principle that I can't seem to solve. The Dependency Inversion Principle states that higher level modules shouldn't depend on lower level ones, ...
I have recently started working on a project where we have a workflow engine which has flexibility to add dynamic states and corresponding actions for each state and all these are stored in database. For example: Workflow Name: Make breakfast Workflow ID : 143 Workflow States state 1 : Turn on stove state Id 1121 ...
I am making this independent drone control system that a user can start and stop. When the program is started, the connected drone takes off, hovers, and turns to face the other side. At first I though of a use case diagram like this: The issue with this is that it seems as if the developer can execute "Take off" etc....
Lets say i'm a new guy coming to the project, how do I clearly determine if there is a debt on the project? What will show it to me? Lets say a certain amount of TD exists at any project. So the next question is: how to measure it? How to quantify the amount of technical debt? Without resorting to metrics (like code co...
I got the following entity and VM: public class Student { public int ID {get;set;} public string FirstName {get;set;} ... } public class StudentVM { public int ID {get;set;} public string FirstName {get;set;} .. } Now, which of the following is a better way to convert one to another (a...
I understand that Annotations aren't directly used in compiled Java programs outside of access through the reflection API or some other means. Annotations, a form of metadata, provide data about a program that is not part of the program itself. Annotations have no direct effect on the operation of the code they an...
I am currently working on a web application as a learning project, which has a NodeJS backend and uses a MongoDB database; however, I believe my question is not specific to the technologies I am using. When creating a RESTful API, I can appreciate that you should always respond to the client with the appropriate HTTP e...
Suppose I have long method like this: public void SomeLongMethod() { // Some task #1 ... // Some task #2 ... } This method doesn't have any repetitive parts that should be moved to separate method or local function. There are many people (including me) who think that long methods are code smells. Als...
I am working on a project of an online service provider. I have tables for admin, agent, customer and tables for data storage like city, services, category, sub-category, gender. I have created classes for the admin, customer and agent. But should I create classes for city, services, category, etc or use as methods in...
EDIT: The project is about creating an algorithm for Procedural Content Generation for a videogame. The actual game is secondary to the algorithm. It must be something basic to test the Procedural Content Generation. I'm approaching this as a single developer. Thanks to @ThomasOwens I realize this question is more abou...
Background I've recently become the technical lead/senior developer for a small R&D/data science team. I've got a decent amount of non-lead experience in bigger development teams, but I've not got any formal education in project or team management. There are a few experienced programmers on the team, but the others hav...
For a data structure with indices (e.g. an array list, a dynamic array, etc...), should the indices be of type size_t or int? Is there a clear reason to use one over the other? fooGetByIndex(struct foo* foo, size_t index); or fooGetByIndex(struct foo* foo, int index); Until I had it suggested to me to use size_t I'd ...
I'm currently creating a small single page app for myself. I'm using Angular and ASP.Net Core 2 Web API. On the server side, I'm also using the DDD approach (just for learning purposes, the app isn't big enough for using DDD reasonably), therefore I'm mapping my Domain Entities to DTOs. Here is an example of an domain ...
I often hear about agility processes, but it seems to me that it is (nearly) always tied to team organization and delivery processes. It (nearly, once again) never comes to the bottom of the bottle: the development itself. Are there any agile methods which specifically target technical issues, like development methodol...
Let's say we're talking about a webshop. Microservice 1: Manages products and their prices Microservice 2: Responsible for payment and checkout. If a user wants to pay for a product, the payment service is invoked. The service has to return success or failure synchronously. Also the service has to guarantee to use ...
I've been trying to make my code cleaner and I have came across an issue which I don't know what the best solution is. This is the code I want to "clean". Please bare in mind that I am refactoring this code and its is not complete. I have replaced code with comments so to focus on the target issue. void Order::cancel()...
I would like to create a system which handles alert messages from various programs and can process those alerts to down-wind consumers via email. This would all be contained over one internal network. I think I want the basic architecture to look something like this: The main concern I have currently is the "Message H...
I am trying to write a rest GET api to serve query results. The entire flow happening on the server is: Fetch user data Call the first query, if results generated: return results, else continue Call the second query, if results generated: return results, else continue And and continue so on. The problem is I w...
Consider this simple example: def a(val_x, val_y): return 5 + b(val_x, val_y) def b(val_x, val_y): return 1 + c(val_x, val_y) def c(val_x, val_y): return val_x * val_y Passing the arguments val_x, val_y from a to b to c seems like a common code smell (I know it is something I do all too often when protot...
I currently am in charge of networked linux based hardware that exposes HTTP connections. I want to be able to connect to these through HTTPS, but the hardware deployment has 1000's of installations. I've read about problems with self-signed certificates and am unsure how to proceeed. Furthermore, some of these may...
Both the comma operator and the semicolon can be used to separate statements. Let's consider this simple code: #include <stdio.h> void do_something(int*i) {(*i)++;} int main() { int i; scanf("%d", &i), i++, do_something((i++, &i)), printf("i is now %d\n", i); if(i == 5) printf("MAGIC NUMBER\n"...
I am working on a huge application in php which contains almost 600 tables to work with, not to mention it requires complex joining for 10 or 15 tables together. i wanted to ask how much ORM is good to use for this kind of task? i know i can pretty straight forward achieved this writing raw queries on database layer. S...
I have a model where Sellers can sell Products to Customers. Sellers need to be able to set Preferences for Customers on a specific Product. I can see how that may be confusing so let me give an example. The Seller is selling Shoes, so he wants to set specific Shoes preferences for Customer x (colour, material, brand, ...
I need to compute the value of a row R on a table based on rows queried on another table B. I need to do it in a queue worker because the computation of the value can be slow. A message is queued everytime B change. If the two workers start the computation of row R almost at the same time, and the data on table B chang...
In our environment: Internal releases are those which went through testing process. Builds either pass or fail. External releases are those which are delivered to users. For external releases, version number is surely given. But is it necessary to assign version number for internal releases ?
Suppose were testing line segment intersections, and the intersections consider parallel and collinear lines to never intersect. Which one would be more natural to write? One case has more jammed into it and the scenario title seems broad, but prevents having to write a certain variable multiple times, but at the expen...
I know about MVC, But I don't have such experience with AngularJS. But both has controller and View. To develope like e-commerce site, is it good choice to choose AngularJS to do filtering with brands, or color, etc. I hope most of the e-commerce site are using SPA(Single page application). When I read about Angular...
Houses and cars have almost nothing in common for instance "number of rooms" and "gearbox". But if you live in an RV then I suppose it makes sense to have both. My problem is that I have a main data model named "Ad" for online classified advertisements and now we are going to expand the section about cars. Should I the...
I wrote a listener class that executes a programmer specified callback. The msg is provided as a callback argument. I realized that a programmer using the class will need to look at my code to see the structure of the msg. Is there a way of providing type hints to callback functions. Or should i refactor my callback t...
How do you cope with a team who tends to underestimate time needed to complete tasks and haven't been improving the accuracy of their estimates? Details: I work in a scrum team (7 engineers) in a FANG company, at the end of every sprint, we vote to estimate how many hours we need to spend on each user story for next sp...
The comments system that I'm using right now saves replies to a comment with that comment id as a parent. The problem is that that if the user of the main comment deletes his comment none of the replies of that comment will show on the page anymore. I think that's okay if only one or two comments are replies directly t...
Unsupervised learning (USL) is about learning/constructing the algorithm to find the hidden data pattern based on training data without hard coded business rules like arithmetic sum, etc. Example of USL is grouping customers with similar online behaviors for a marketing campaign. My question is why do we need training/...
Is it generally encouraged or discouraged to create a pre-processor macro in C, that facilitates the creation of many functions with the same signature (differing only in name). For instance, instead of: obj *car(const obj *args, obj **envp, GarbageCollector *gc) { ... } obj *cdr(const obj *args, obj **envp, GarbageCol...
I find this concept hard to understand. So in what situations we have solutions that are impractical or impossible like those P-systems try to implement? P-systems are described as: P-type [practical - type] This is a software with a collection of procedures. This is defined by exactly what procedures can do. In this...
Consider the following minimal example: class SomeException < StandardError end class Example @@logger = Logger.new @@failure_count = 0 def do_a_thing(array) raise SomeException unless array.some_check? # more random code end def some_long_process(array) array.each do |item| begin ...
After reading the last book from Robert C. Martin, I've tried a to develop some big Go applications following clean architecture. While writing interactors, I end up with a lot of complex unit tests, because the interactor has a lot of external dependencies. What are the best practices for testing the interactors? Shou...
I am new to an organization that has a release version number for their vision software and a different release version number for the supporting functionality (dvr, provisioning, etc) around that vision software. It is straight C code - everything is global, very tightly coupled and the components do not compile separ...
I need to make an HTTP endpoint with different return types based on query params. There are several options to do that: Return an object with one property set and the rest equal to null: public class ResponseModel { Type1 Property1 { set; get; } Type2 Property2 { set; get; } Type3 Property3 { set; get; } }...
// Car states : START, RUN, STOP // START ==> RUN ==> STOP ==> Write // CarFromStartToStop() : // Car is initailly at STOP phase. // We start the and car comes in RUN phase. // Then at the end car comes in STOP phase. // WriteCarResults() : // Writes car's current status. eg : oil status, odometer etc. class Info1...
Since when I used smarty I always tried to separate logic statements from html tags, so my approach to blade would be to write: template.blade.php <div> <div> @if ($something == true) <ul> @foreach($list as $item) <li> {{ $item->name }} </li> @endforeach ...
Imagine that I am creating and Ecommerce application. For sake of simplicity, I will describe only 3 bounded contexts. Product Catalog: it's responsible for maintain product descriptions, characteristics and so on Pricing: it's responsible for products pricing Inventory: it's responsible for inventory management. If ...
Back ground: 1) Waterfall model has it's own phases of SDLC: Requirements -> Design -> Implementation -> Verification -> Maintenance 2) Iterative model has it's own phases of SDLC: But the term Agile does not have it's own development methodology. Agile projects are mostly iterative in sofar . Is Agile an effort pla...
On the project I'm working on, I noticed that on login there is a check in backend which checks if the request is an ajax reques (checks 'X-Requested-With: XMLHttpRequest') or not. If the request is an ajax request the login is performed, otherwise the request if deniend. Nobody knows why this check is needed here and ...
People say that "talking about TDD hardly works, if you want to convince someone to TDD, show them results". However, I'm already getting great results without TDD. Showing me that people who use TDD get good results won't be convincing, I want to see that people who write both TDD and not-TDD get better results with T...
I'm developing a game engine in C# and I just had a question about handling exceptions correctly. Since the engine will be used by other .NET developers, how should I handle exceptions? What I mean is, in any other application that may be used by people outside of the development if an exception is caught, the program ...
I have a situation where some commands are using some common methods. These were originally developed in one command and are now helpful to other commands, they can be static and are self contained. public Command1 : ICommand { // does something specific to some records // tidying up fields before they go to the...
I have the following basic design points: Let's say I need to design 2 entities, ADecoder and BDecoder, which are almost the same, except for few details. Let's say both have a function decode() which of course would be separate in what they do, and there are some other functions as well, with the same characteristic,...
I would like to implement gambling website with the following possibilities: as a player I would like to get list of games As a player I would like to like games As a player I would like to see recommended games(based on likes or time spent on a particular game by users) As a player I would like to start/end a partic...
We develop on a ASP.NET Web API where we use the "Unit Of Work / Repository" pattern : Our Controllers looks like that : public class MyController : Controller { private IUnitOfWork _unitOfWork; private IMyService _myService; public MyController(IUnitOfWork unitOfWork, IMyService myService) { _...
These days we follow TDD across projects in the company. How as a leader I will know whether TDD is truly followed within a project? I would like to achieve this through automation that is instead of manually auditing, would like to see some tool to monitor the developers workbench constantly and alert if TDD approach ...
I'm not sure if softwareengineering exchange is right for the question. I need to populate view model with some values I query from the database. I do it like: var db = new NPoco.Database(connection); // Get some values from database //... var viewModel = new MyViewModel(db) { //assign values from database }; // sho...
I am writing tests for a project that consists of multiple submodules. Each test case that I have written runs independent of each other and I clear all data between tests. Even though the tests run independently, I am considering enforcing an execution order, as some cases require more than one submodule. For example,...
I am writing a simple compiler. I have written lexer and parser and it now generates assembly code from given code. Now I need to write an assembler which generates machine code. But the problem is that I want to make my compiler portable. it should run at least on major architectures. One way of doing it is writing di...
Is there a best practice for iterations inside of a "using"? which is better? and maybe a why? "using" inside of an iteration... foreach (var currentPerson in Persons) { using (var db = new SolutionModel()) { //TODO: run query } } or is it better to do an iteration inside of a "using"... using (va...
In official Microsoft docs: ✓ DO use a stable, version-independent product name at the second level of a namespace name. But in Reference Source, the following namespaces ends with Version: Microsoft.Build.Tasks.v4.0 Microsoft.Build.Utilities.v4.0 Microsoft.Build.Utilities.v3.5 So is Microsoft violating its o...
In the book Coders at work Joe Armstrong stated that: I think the lack of reusability comes in object oriented languages, not in functional languages. Because the problem with object oriented languages is they’ve got all this implicit environment that they carry around with them. You wanted a banana but what you...
I am designing a library that abstracts a typical CRUD http service named FooService. In this library I am throwing different exceptions like FooServiceClientException for network related errors or FooServiceObjectNotFound when trying to retrieve an object by a non-existing id. I also have a FooServiceException from wh...
Situation I am currently refactoring existing web code. The code currently revolves around a ServerConfiguration object. It looks something like this: string UrlBase = "https://myserver.com/api" string UrlLogin = "/v1/login"; string UrlProjects = "/v1/projects?api_token={0}"; public string GetLoginUrl() { ...
public class Connection : IConnection { public Connection(Uri baseAddress, ISerializer serializer) { BaseAddress = baseAddress; Serializer = serializer; ResponseFactory = new ResponseFactory(serializer); } private Uri BaseAddress { get; set; } public IResponseFactory Resp...
If I want to create a conceptual model for my new application, and during the analysis, I found that some objects like employee, department ..etc are a part of another system. and all the data related to them like employee name or number exist in that system. My questions here: How to handle this case in my conceptual...
I've been reading Out of the Tar Pit by Ben Moseley and Peter Marks and in section 5.2.3 they discuss state in functional languages compared to procedural languages. The procedural example is as follows: procedure int getNextCounter() // 'counter' is declared and initialized elsewhere in the code counter := counter...
I'm putting together a talk of the history of best practices in software development and we're trying to put together a bit of a timeline of how good practice has evolved. This question talks about the history of Source Control and talks about how the first versions started to appear in the 80s but I'm hoping we can go...
While working in a multi-threaded environment, then data sharing seems to be a good option to pass data between threads. While working with real time systems it is apparently advisable to go with memory optimization. So, in my scenario, I have one consumer and one producer. They share one queue of any data type e.g i...
I'm currently learning functional programming and trying to learn a new concept : transducers. I'm actually getting the point of theory, like it's an advanced map/reduce that aims to provide better time complexity on array / object operations (such as transform / filter / reduce). Here's my current code, I'm feeling a ...
I have a function that creates a new object by passing to it's constructor integer ids primarily with values of 0. This function is called when saving a newly created record (not an edit). public class RecordController { private int _recordId; private int _subRecordId; private string _xmlData; private...
The issue at hand is dealing with user avatars that come from their social media accounts. When a user signs up with our app, the user will use his/her social media account and we simply save the URL to user's avatar in our database. We're now running into an issue because in a NoSQL database, we're creating many copie...
I only know that index is faster but don't know why is it faster. Suppose I have an array int[] a = {2,3,6,7}. Then I will try to find the element at a[3] and the speed of this will be O(1). Why? How it will know that 3 is placed after 2 boxes? So for more clarification of my question here is the structure of array I'm...
I am currently get a job and faced to a Table with around 900 columns in their database. I am not sure what should I do instead of re-design the database, Please advice me for this situation that I have. Queries for this Table is really frustrating when I need some of the data in this table and joining to other tables....
(Not entirely sure whether this should go in the information-security StackExchange instead; feel free to move it there if that's where it belongs.) Unicode has many, many instances of pairs or larger sets of characters with identical glyphs nevertheless being assigned to separate codepoints (for instance, the Latin ca...
I am trying to design a group of related classes. For example: one table class holds a vector of integer, and has a function returning integers from the vector another table class holds a vector of double, and has a function returning doubles from the vector Ideally I'd like to have the two classes share the same poi...
I want to fix my current Email Delivery system which sends email using a third-party email provider and creates a record for each email sent in RDS. Functionally this is how the system behaves - A user creates Campaign to send emails to their leads. A campaign can be sent to up to 1 million users A created campaign is...
In this article, it is written that in C# 8.0 new feature of convariant return type will be included as the community asking for this feature for quite a long time. Can anybody explain why and when this feature is required with practical example ?
I wonder if I have multiple objects and how to list their responsibilities where every Object Must be Responsible for Itself for example: If I have three objects: Employee,Schedule,Shift. and the setShift(), createShedule(),....etc Where should these behaviors belong to ? in the Employee or in the objects which af...
Consider a social network in which the users upload their images (cover, profile etc). Each image need to have different sizes (ex: large, small, supersmall etc). The upload is done by a API REST json request which contains the file content and some metadata. The json response is the different urls for each size and t...
I know that the way you set up your solution and working environment is subjective at best, but I'm looking for some guidance and possible examples for structuring a solution that uses ASP.NET Core, WebAPI and a repository pattern. I've looked online and within stackoverflow and I have seen lots of examples for variou...
Let's say I'm building a Customer web application(in Spring Boot 2), which also exposes rest end points. I'm modeling my application into 3 layers. a) UI - CustomerDTO b) REST - CustomerRESTResponse/CustomerRESTRequest Service - CustomerDTO Data - Customer (Entity) Does every layer need to have it's own business o...
We have a camera application that does measurements on pictures. We have a feature for saving a "demo" containing the pictures/data used, and to replay this for test purposes. We use such data sets for different tests. We currently have these data sets stored on a server, accessing them directly in the file system. I a...
I have to extend some very badly written Python code (no documentation, very interdependent, barely any encapsulation, very static, everything hard-coded, etc..) and therefore do I obviously have to use some of its black-box, bug-prone functions. Now I don't want to refactor this repository, as I am simply missing the ...
I am having trouble gaining an intuition about UML Use Case Diagrams and what to include in them and what not, starting from a given scenario in prose. I have read through my course materials and the according chapters in "Software Engineering (Sommerville)" and "Use Case Modelling (Bittner)". However, I still struggle...
We have a python scheduling solution which, at the moment dynamically loads python modules to run each job in a separate process. The jobs are pretty heavy containing some Tensorflow models which process data retrieved from shared drives or databases and inserting the results back into databases. I have the task of mai...
I have many classes that retrieve databases objects. I have implemented their methods as static, so they can be called like this: class xxxDB { public static method1(Connection dbcon) { //... method2(dbcon, ...); } public static method2(Connection dbcon, ....) { //... } // Other specifi...
In my work we've been tasked with implementing two factor authentication across a number of our web applications which currently share a credentials database (asp.net forms authentication) but have their own code for collecting and validating credentials etc. In thinking through this problem I've reasoned that this mig...
I am creating a project related to education system in which data of universities ,admission and scholarships will be gathered and displayed on site. In this project I am scraping data from different sites, storing it into database and making it view on site. Actually you can say (correct me if I am wrong) the system i...
I have some standard which changes in time. Let's say I have std_v1, std_v2 and std_v3. Those standards have a lot of common parts with some little differences, possible additions and deletions. On top of those standards, I have several concrete implementations, which have a small number of changes. Right now my class...
I'm using the Tone.js library to build a (music) sequencer in Vue+Vuex, and have encountered this problem: Individual music tracks of the sequencer are created dynamically, so I'm storing objects for them on the state, including a reference to their synthesizers (ie: new Tone.Synth()) ... when these synths are played ...
A lot of people follow the following paradigm: fields are always private. properties are only used to expose fields, thus should only be public. There are plenty of exceptions to this rule (lazy loading, for example). With auto-properties, I've found it possible to never use fields. If I need my fields to be very basic...
I have a requirement in which at different hierarchy in a xml each node have similar set of properties. But every parent can override its child settings. Its just like the CSS styling over the html element in reverse order. For example <Node1> <settings> ..... Some common properties </settings> <Node2> ...
I am trying to decide whether to use a Domain Service or an Entity method for a function. Please see the code below: public class Customer { private readonly Guid _id; private readonly decimal _expenditure; private readonly IList<IProduct> _eligibleProducts = new List<IProduct>(); public IE...
I'm confused in architecture solution for boolean expression tree. Business logic has algo to parse config and make a tree from such expressions. (a && b || c) && d || (e && f) So in UI a,b,c,d,e is cells, they can be swapped (via dnd). () - is layer(s), which can be or can not be in expression. a && b && c - has no ...
We've been using BEM for several Drupal CMS projects quite successfully. This means we've been following a frontend-first approach where frontend developers specify the HTML, which is then implemented backend-side. In Drupal 8 where we have Twig templates this isn't a big problem. It's also conducive that Drupal 8 uses...
Assuming I have the following (very simple) class class Foo { public: void setAB(int a, int b) { m_a = a; m_b = b; m_aIsBigger = a > b; } int getA() const { return m_a; } int getB() const { return m_b; } bool isABigger() const { return m_aIsBigger; } protected: int m_a; int m_b; bool m...
We had in our system in the past an external data provider (call it source) sending regular heartbeats to a java application (call it client). If the heartbeat failed, system shut itself down (to avoid serving stale data in a critical application). This was straightforward as both data and heartbeat used the same chann...
I have a vector that stores multiple instances of a type T: std::vector<T> vec; From time to time, vec is being sorted for different purposes. Now, I need a list of pairs of objects stored in vec, but (because of the reordering of vec) simply storing the indices is not suitable. Using the list of pairs, I would like t...
Problem: Winform app for servicing different types of devices (approx. 10 types). Some devices have more settings similar (or same) then the others. Each device could also has software and hardware versions which could change the number of settings. Every device has big number of settings divided into pages (tabs) an...
I need to write a basic code indexer, which needs to be fast. Should I use an embedded SQLite database for this or should rather rely on a custom data structure, or even flat files as used by ctags? Some of my requirements: Find all references of a variable. Go to function implementation etc... Any pointers to docs ...
We have a REST web service written in C# in ASP.NET MVC/WebAPI. When the underlying data store fails, this can lead to our service being completely unavailable, instantly. There is currently no caching of data in the service. We're exploring caching patterns, however I have a feeling that our approach isn't going to ...
I've heard circular references are generally an issue, however I was wondering if this was true for interfaces that reference other interfaces, for example: IQuestion{ IAnswer getCorrectAnswer(); IList<IAnswer> getAllAnswers(); } IAnswer{ IQuestion getQuestionInResponseTo(); } Is there any case where this...