instruction
stringlengths
34
36.1k
I have library with asynchronous thread and application who use them. Application can pass object to library of type provide by library interface. If application does not create new instance of object and pass for example object which is use to presentation layer than application be suspended for a few seconds may cras...
If all data types are made non-recursive using tricks like a table of node IDs linking to data and data uses only other node IDs to form a graph, then can all memory be managed using just Reference Counting? Furthermore is it possible to express a immutable list with the standard set of Haskell-like functions for the l...
I'm working on the structure of the fields that are persistent in my Unity game. Things like inventory, etc. It is saved by serializing a class and saving to disk (as explained here). The problem I'm having is figuring out the best practice to structure it all. I want 2 classes that can access it - one that checks and ...
Can I use the crypt() function in my commercial software source? if I want to use crypt() I have to add #define _XOPEN_SOURCE that's why I m asking this question. Can I use #define _XOPEN_SOURCE in my commercial software source?
I know this question is kind of broad, but all I really need is some best-practice code structure or a link to a good tutorial. I am working on a CRM that runs on php and mysql. Currently, our search query looks something like this: SELECT * FROM contacts WHERE name LIKE '%ric flair%' Now, that's really dumbed down, bu...
I was trying to find alternatives to the use of global variable in some legacy code. But this question is not about the technical alternatives, I'm mainly concerned about the terminology. The obvious solution is to pass a parameter into the function instead of using a global. In this legacy codebase that would mean th...
This my proposed structure for my C# program. My LIN Comms Object/Thread. Reads data from LIN, and fires two events (data received and data changed) then check to see if there is any in the write queue if so it writes then repeats if not it repeats I would like to know if there is another way to structure my Mai...
What is a technique in MVC that can be used to trigger updates? Namely, When user clicks a button save a product I have this: function saveProduct($product) { $this->repository->saveProduct($product); } But addition of (any) product must trigger a global state update. I did it like so: function saveProduct($produ...
Is there a way to use the existing features of object oriented programming languages to work around the square/rectangle problem? Can a child be defined in terms of being a more restrictive subset of its parent class rather than being defined in terms of additional features? Former question: I'm trying to reconcile th...
I have the opportunity to work on a project to create a phone app. I have been given a document that's about 60 words total. There are a couple of phone calls and SMS message too, but it's clear to me that I'm going to have to work hard, just to figure out how hard I'm going to have to work. In the software industry, i...
My question is similar to (but not exactly the same as) this question. This question was also helpful but it is less similar to my current question than the previous question that I linked to. I have a framework that runs automated testing. Basically, an XML "script" has data on which methods to call against our API; o...
Now that we have Red Black trees and AVL trees, it means that inserts and deletes take log(N) time. (We also note that find_min() would take log(N) time). Comparing these to heap, we have same complexities. However the above mentioned trees are BST so we can search in log(N) there. All in all I don't understand how hea...
What do you call a class that has methods that take input (from user, from GET or POST) transform it to a business object and return that object example ... class Input { function getObject(array $input) { $o = new Object(); $o->setVars($input); return $o; } } $o = (new Input())-...
In my application I have quite a few service classes that act as a façade and delegate most calls to one or more underlying manager classes. I've read very different opinions on how to test such façades. Some people say it's not necessary to test them at all, others say one should test whether the integration is workin...
I'm developing a largeish application that will have custom finite state machines. That is, the admin users of the application will be able to create their own state machines, limited by little pieces of code that are pré built, lets call those tasks. OK that is all fine and we are reaching a place where we think its g...
I have a system that uses CQRS with the Queries written using Dapper. It's worked out well, except that there has been a proliferation of query classes that do almost the same thing. The downside of this is that additional queries mean additional maintenance overhead (especially because of the SQL strings) and other pr...
I understand what increment and decrements operators are (++ and --) and the difference between post and pre (i++ vs ++i) but should they be avoided as they do increase the difficulty of reading the code? After reading the answers to the question Are assignments in the condition part of conditionals a bad practice? it ...
I'm not sure whether I'm using the correct terminology here. I'm trying to come up with an algorithm that let's me find a vertex in an arbitrary graph so that the vertex has minimum distance to the farthest vertices. And additionally, I'm also trying to come up with an algorithm that let's me find 2 vertices instead...
When a modern OS loads a process, it pre-allocates a certain amount of space for stack. This means that the programmer has to be careful to avoid stack overflow by limiting call depth and/or by increasing the stack size in run-time. At first glance, this seems unnecessarily complicated. Why doesn't the OS implement the...
Let's have this C# class (it would be almost the same in Java) public class MyClass { public string A {get; set;} public string B {get; set;} public override bool Equals(object obj) { var item = obj as MyClass; if (item == null || this.A == null || item.A == null) { return...
How can I handle the situation when exists the context that represents a collection of arbitrary objects? This context can be created by code like this: $context = new Context(); $context->add(new Category($current_category_id)); $context->add(new Filter($one_filter_id)); $context->add(new Filter($another_filter_id)); ...
I have a program that makes hundreds of daily CURL requests, SMTP request, and other requests. Less than 1 percent of the time, a CURL or SMTP request will fail. Best I can tell, the cause of the problem is external and can not be fixed to be 100% reliable. My program is always able to recover from it and no human inte...
The business team in my company has come up with a new field to add to one of our entities. For new instances of this entity, it'll be calculated dynamically, but for previously existing instances, we need to set up a default value of, at the moment, 15. I can easily set that as the default value in the db, but to me, ...
I had problems finding a good question title, so feel free to improve on that. I want to implement an Entity Component System in C++, and wish to use TDD for the first time. Now I have doubts about how useful TDD is when the target "architecture" is already specified, but want to try it anyway. My problem is more of a ...
The EntityFramework Reverse POCO Generator is a Visual Studio extension / T4 template which derives from the PetaPoco template. The PetaPoco project is licensed as Apache 2.0; and the derived work is labelled as being distributed under Apache 2.0 as well. However, the author has added a clause to the top of the LICENS...
Probably I am missing some key aspect here, because I simply have no idea how this metric is supposed to tell me anything described by the authors: Defect Open and Close rate = (Defects found during testing in a release / (Defects found during testing in a release + Defects found after release) *100 What is it? Wh...
Is it good practice to store Nuget or NPM (or other) packages in the source control with the source, or to keep them in some other place? My gut says they belong with the source, however a package will probably version less often then the source, i.e. when a release version is created. I'm wondering what others people ...
I'm trying to come up with an algorithm that allows me to find two vertices in an undirected, weighted graph that minimizes the distance to the farthest point. Distance of the farthest point is basically the distance between two vertices (u, v) in the graph such that distance(u,v) >= distance(x,y) for any two other ver...
As a budding software engineer, what is worth time-investment in terms of Javascript? I'm interested in long term payoffs in terms of a deeper understanding of languages, tech, software engineering, etc. over just using languages. I really like JavaScript's prototype model and am perfectly comfortable implementing obje...
I'm doing some research on authentication methods and I've noticed that not only does Azure call their cloud Active Directory interface API the "Graph API" but also Facebook use the same term with their "Open Graph API". What does the word "Graph" actually mean in the context of user identity? Is this just coincidence ...
I am prototyping a bluetooth headset. Wondering whether it is possible to buy an existing bluetooth headset, connect it to a computer and reprogram it (i.e. change the behaviour of the buttons etc.). If yes, how? Where can I learn more? I am a complete beginner, so if it is not fundamentally possible to do, what are my...
There are some things I am pretty strict about, but const has not been one of them. For example, I might make a local variable that I use three times in a function, that does not get changed, and yet I do not bother making it const. Is this something that I should be more strict about? Are there any tangible benefits t...
I have attached the problem below with the answer. My problem is that I can't understand it. Can you provide an overall explanation in detail about parse trees and ETF grammar by deriving the first expression? Just try to explain the first expression, a+b/c+d. I think it's not that hard, but I just haven't been able t...
I don't want to say that is not necessary knowing design patterns. I just want to tell you my experience. I've used Spring frameworks for four years and another frameworks (JSF, Mybatis, Hibernate, etc) in various projects where I've participated (I work as Java Developer). In all this time, I've used few design patter...
I have a client which depends on data fetching from two different domains. Client fetches the data from Domain "A"'s API layer and Domain "A"'s Data Depends on Domain "B" There is an implementation on Domain "A" services layer to call HTTP Request to Domain "B" s API layer. What I feel is we should fetch data by Using...
A trace table is a technique used to test algorithms. "The table usually takes the form of a multi-column, multi-row table; With each column showing a variable, and each row showing each number input into the algorithm and the subsequent values of the variables." ~ Wikipedia Whereas in a pure functional language ...
I have a 2D boolean array for example: 01000000 01110000 00110000 01100000 00100000 00111100 00000000 00000000 What I want is to efficiently create a scaled representation for this array according to some size, in example, if the size is 4x4 then the above array will be paratitioned to some 4x4 parts: 0100 0000 0111 0...
I have multiple projects that I am involved in, and for one of those I have worked for 2 years and delivered a piece of software that is being used in production at customer site. Everything went really great and customer got back several months after the initial release and said that they want to make some modificati...
Whenever I am asked how I would scale out an application I inevitably tend toward a queueing model: split the application responsibilities into individual services and add queues between those services. This means you can spin up more or less instances of a given service as required and they simply pull from the queue ...
I´m currently creating my first restful API for a WebApp and I´m at a point where I´m not sure, how to best structuring it. Background Information I´m developing a Holiday planer for a Company. The company is separated in a few departments. So some users are in Department A and some in B for example. The department inf...
I have a discussion with a colleague. He thinks we should inject a mapping class (for mapping the domainmodel to a viewmodel) in a controller. He thinks we now can test the mapping class (which is an automapper class for some properties) and we can inject another implementation when we need it. My opinion is that the l...
Suppose I have a method like this: public int CalculateAge(DateTime birthDate) Is this a Command? Query? Or should it be separated and not included as either a command or query? It fits the query interface (TOut Execute(TIn input), but it's conceptually not a query, more of a mutator. For a command we would need to ...
My colleagues and I are struggling with a design problem. I'll try and explain the situation: We have a number of different components (let's call them plugins), that take an input, do something with it, and give an output back. Each plugin takes a different number (and different types of) inputs, and gives back a di...
I got a trainee in the company I work for. We are currently working on a JS interface that communicates through websocket with a C/Lang server. My trainee asked me a very good question this morning. I quote : "I understand the system of sending and receiving messages, but how the computer actually receives and for...
In a recent question, there's a debate whether or not an arbitrary default value in the definition of a column in a table is considered having business logic in the database. As we know, if an insert statement fails to provide a value for a given column, such default is inserted instead of null. My question is, besides...
The company I work at has a (in my opinion) slow build process. We use TFS, and checking in code takes several hours. It goes like this: (Assuming change is made and code review has been approved) First, you make your change and submit it for a preapproval step via a button in visual studio. This builds the entire visu...
In a recent project of mine, I defined a class with the following header: public class Node extends ArrayList<Node> { ... } However, after discussing with my CS professor, he stated that the class would both be "horrible for memory" and "bad practice". I have not found the first to be particularly true, and the se...
Somewhere I have read that "Object Oriented" is a misnomer and that OO should really stand for "message-oriented programming". What I am not clear about is ... what does it mean? For example in procedural style you could do : /* * Assume that $rawInput is an array * and that function clean_raw_input returns an array...
From Wikipedia on Single responsibility principle SoC ... class should have responsibility over a single part of the functionality provided by the software, and that responsibility should be entirely encapsulated by the class. All its services should be narrowly aligned with that responsibility class or module should ...
Can someone explain if the context diagrams(as used in requirements engineering) have cardinalities(as defined in UML diagrams)? What I want to ask is, are cardinalities part of a context diagram's syntax?
What type of software architecture style does the MEAN stack most resemble? I am thinking Client/ Server because of the way messages are communicated between the different modules in both. However, I'm not confident and would like some other people's opinion. Thanks in advance
All of my projects up to this point have been solo (I develop single page web applications). I've always used an IDE which automatically uploads changes to a test Amazon EC2 server over SFTP and I simply refresh my browser page to see the changes. Then when Ive got a stable result, I upload the changes to my production...
The replies in this post come very strongly against including headers inside a namespace and Doxygen is confused if that is done (which suggests that its team did not consider that usage either). I would like to ask whether including headers inside a namespace is justified in the following case. I am developing a heade...
I often wonder why Java uses :: for method references instead of ., e.g. why write System.out::println instead of System.out.println Of course, one might simply answer: "because the designers decided so". On the other hand, I would have expected the second syntax because the dot is the usual Java syntax for acces...
I am writing a simple Java app to run weekly. The app need call database to get data, check it and update. The flow I need is little as following: select configure,orgID where status=true from orgs; orgs has thousands of rows, configure is blob Check blob object configure, and filtered the orgID list for filtered or...
Let's assume I have two classes that look like this (the first block of code and the general problem are related to C#): class A { public int IntProperty { get; set; } } class B { public int IntProperty { get; set; } } These classes cannot be changed in any way (they are part of a 3rd party assembly). There...
Is it ok if I include many PHP file within a PHP file? What is the best practice? Or where can I learn the best basic practice of writing PHP? Why I do this Is because I often can change the content of each div through the PHP file instead of directly change in the main PHP file.
I'm writing javascript object that wraps REST requests. For every operation on the server there is a method that accepts the parameters for the request and a callback that will receive the results. (The method issues a jQuery $.ajax()-call and prepares the settings for $.ajax().) Each method has the same structure: c...
I have a strong Java/Groovy background and I've been assigned to a team that maintain quite a big C code base for an administrative software. Some pain points, like dealing with blob in the database or generating reports in PDF and Excel have been externalized to java web service. However, as a Java dev, I'm a bit co...
We are currently devloping a ASP MVC Webapplication. In this Webapplication, we have a User that can have 1 or many contracts. We currently have 2 controller: UserController ContractController Now we want to display all Contracts for a User. Which of the above Controllers should contain the Action to List all Contrac...
In our application, we have a pojo mapped to some entity. One pojo refers to one entry in DB. There are multiple steps for it's life-cycle. It gets created freshly, it goes 'live', after some calculations it either gets disabled or goes 'live' for something like plan B processing and then finally ends it's journey. Pro...
I read somewhere that C is preferred for drivers and firmware on embedded systems because it requires less run-time support. I could not understand the part 'run-time support'. My understanding is C code is converted to assembly code, which is flashed on a embedded device in form of a binary file. Please correct me, if...
How is Bytecode "parsed"? It is my understand that Bytecode is a binary, intermediate representation of the syntax of a given programming language. Certain programming languages convert their source text into Bytecode which is then written to a file. How does the Virtual Machines of those languages "parse" their Bytec...
Say I have the following ER diagram: Now if I represented the relationship using a foreign key of School in Student, I could have NULL values (because a Student is not required to belong to a School), for example: So the correct way (based on what I have read) is to create an intersection table to represent the relat...
I am trying to wrap my head around having a secure WEB API and at the same time securing the client that accesses the WEB API. I am hoping someone can point me in the right direction. Here is my scenario. I have developed a WEB API that has an authentication method that takes a username/password and upon success authe...
I am writing a small program that is a client of some protocol. I wanted this program to have a filesystem database. the main directory would contain one directory for a server that is configured, and the server directory would contain things like server settings in json and other data, this time those are certificates...
We work on a fairly large casino/gaming/wallet/lottery platform. It's a turn-key application that is currently in use by 4 clients, and soon to be much more. I've made some bullet points regarding the architecture below: ~130K LOC in just C# code over 500 stored procs, in one of the 5 databases our system uses - becau...
I've created a Java project based on a C# sample application that was published under the Code Project Open License (CPOL) which sounds to me quite similar to MIT. As I was the only user of this library for a while I didn't care too much about the concrete licensing. However, I was asked recently to choose one so other...
Using gitflow, when creating a release-1.0.0 branch and merging it to both master and develop, both branches will have a missing commit: master wont have the commit where release-1.0.0 was merge to develop develop wont have the commit where release-1.0.0 was merge to master Instead, after hotfix-1.0.1 is created and ...
I have heard this term a couple of times. What exactly does a Cloud-Native application refers to? What are the features of a Cloud-Native applications?
Java 8 added the concept of functional interfaces, as well as numerous new methods that are designed to take functional interfaces. Instances of these interfaces can be succinctly created using method reference expressions (e.g. SomeClass::someMethod) and lambda expressions (e.g. (x, y) -> x + y). A colleague and I ha...
I'm a front-end web developer and currently facing a situation where I have one form with few parameters of one object and to save them I should make few requests to few different API endpoints. As I'm used to REST ideology I suppose to have only one API to save one resource. There is some entity, some object with huge...
The Problem We are currently architecting our new Notification Microservice but having trouble with how to handle aggregated emails. What we need to do is instead of sending one email every action performed (could be 20+ in a few minutes), we would send an email after an hour summarizing all the actions that were compl...
I started a new job recently where I am working on a very large application (15M loc). In my previous job we had a similarly large application but (for better or for worse) we used OSGi, which meant the application was broken down into lots of microservices that could be independently changed, compiled, and deployed. T...
I have a situation where my ASP.NET MVC application can be loaded directly or in iframe. It uses ASP.NET Identity. When I open the site from iframe, log in and after open the site directly it keeps me logged in. Is that a normal behavior? Is session shared between apps opened directly and in iframe? Here are more detai...
We are developing the application with MVC and Repository Pattern. Currently we are using EF as an ORM. But Later we need to change the ORM to nHibernate. Any Idea on the architecture. Currently I plan the architecture as Contracts: Model/Entities/Repository-Interface/Service-Interface DataLayer(Reference Contracts...
The following code says that c1 == c2 and c2 == c3, but c1 != c3. TOL = 0.11 class C: def __init__(self, x): self.x = x def __eq__(self, other): return abs(self.x - other.x) <= TOL c1 = C(1.1) c2 = C(1.2) c3 = C(1.3) print(c1 == c2) # True print(c2 == c3) # True print(c1 == c3) # False F...
I can write code like: var dependency = "Hello!" var something = new Something(dependency); something.DoStuffWithDependency(); Or I could write it like: var dependency = "Hello!" var something = new Something(); something.DoStuff(dependency); Where the first example takes the dependency in the constructor and uses it...
At my workplace we're soon going to be tasked with removing SQL injection vulnerabilities from a large code base. The application was originally written around 8 years ago and after years of bolt-ons and additional features, security is finally getting looked at. We'll be moving from using the mysql_ extension to PDO a...
I was wondering if anyone out there has general tips for how to structure an iOS app backed by a REST api. There are basically two approaches to this that I've thought of API calls placed ad hoc in the view controllers. In this approach the view controller has some state that it fetches from the backend such as a Use...
I've been reading the OAuth 1.0a RFC: https://www.rfc-editor.org/rfc/rfc5849 . Most of it is pretty clear. However, I have a few questions: I can't understand why the oauth_callback is sent when obtaining an unauthorized request token. I mean, doesn't it make more sense for it to be sent when redirecting the user to t...
Let's say I have this example. There is a chef (actor) and a Use Case cook food. If there are 2 food options to cook (lets say pasta and pizza). Should I create 1 Use Case : CookFood and then in variations section add Pasta and Pizza, or should I create 2 use cases : CookPasta and CookPizza.
Apologies if "Composition Hierarchy" isn't a thing, but I'll explain what I mean by it in the question. There isn't any OO programmer who hasn't come across a variation of "Keep inheritance hierarchies flat" or "Prefer composition over inheritance" and so on. However, deep composition hierarchies seem problematic as we...
I am learning about the Crow's Foot notation, and there is something that I don't understand, some tutorials shows an Identifying Relationship as having a straight line, and a Non-Identifying Relationship as having a dashed line: While other tutorials shows both relationships as having a straight line: Are both notat...
I would like to solicit some general design principles and best practices to avoid creating a callback pyramid of doom particularly in the Scala language. Consider the following rudimentary and imaginary code snippet: val response: Future[Either[ApiError, Option[CogWidget]]] = services.findCogWidget("Some-UUID-42") res...
Let's say that I have a chatroom application that manages rooms, users, and messages. I'm building this out as an opportunity to practice some service/manager/web separation and teach myself good application design. With the following classes: Model: public class Room { private final String id = UUID.randomUUID().t...
My client has a super Spaghetti codebase structure. Single solution with some hundreds projects in that solution, which are tightly coupled. They think that just using a package manager (like NuGet) is a solution to their problem, they want to create packages from their codebase and put them in their internal reposito...
Lets say I have some sort of unit tests like this: let myApi = new Api(); describe('api', () => { describe('set()', () => { it('should return true when setting a value', () => { assert.equal(myApi.set('foo', 'bar'), true); }); }); describe('get()', () => { it('should return the value when get...
Sometimes I work for a project that requires some programming languages for about 3 months, later I work for another project that requires a different set of languages. I know and studied of of these languages, but the problem is that I keep forgetting a lot of the details, and sometimes I have to re-read a book or wat...
Currently I'm investigating about NCurses library for implement text user interface in C programming language. Curiously today I went to a Car'ls Jr and and there was a monitor like this: Now, my question... is this a terminal application (TUI), why this kind of companies (fast food) use text based applications (it lo...
I am designing an Information System for the French Social security system and would like advice on how to use Ishikawa (fishbone) diagrams to model said information system. My question specifically is about the definition of "environment" in this diagram. What is the common definition for "environment" in such diagram...
We have an mvc application that we would like to gradually move to an angular platform. It is a wizard style app with 6-8 pages. We currently have a classic mvc layout. We would like to move to an angular2 project structure. Our current approach is to rewrite one page at a time, but we also have to provide improvement...
I am a bit confused regarding module loaders Like I am using webpack which load modules as chunks but it is only while developing When the code gets minified it will be a single file for all scripts and css and there how the module loaders work? Any explanation would be appreciated
First time posting. I know this is a very generalized question, sorry for that, I don't know how to more appropriately word this. I've noticed a trend, a pattern in methods, it seems in almost all methods, for example, in Java (haven't programmed much in other languages although I would imagine it's the same) the metho...
I'm studying for the CPRE Foundation Level exam from the International Requirements Engineering Board. In the exam, there is a statement: Quality Requirements are elicited after the Functional Requirements. The answer to this statement is provided as false. Does this mean that quality requirements should be elicited ...
I run an automated data collection service at work, which records measurements (temperatures, voltages, etc) from about a dozen sensors at a rate of about once a second. The MySQL database table looks like this fictitious example: TABLE: recorded_measurements ************************************** id sensor measu...
I was reading the post A Modern Architecture for FP that included a code snippet that the author wanted to decompose further. I don't know Haskell but I recognize enough to know that I've written many functions like this one, combining related logging, metrics, and business logic in one function: saveFile :: Path -> By...
Okay, I'm trying to write something resembling a 3D game engine. That means I have to deal with matrix transformations and similar stuff. For any of you who don't know, you need to use three basic matrices to define where a vertex will be positioned on the screen: projection matrix, view matrix and entity matrix. View ...
while cond1 ... if cond2 ... else ... break The while loop above has two termination conditions, cond2 and !cond1 !cond2 When the commands that are represented by ... are long, I feel the code is not easy to understand. The two termination conditions for the same while-loop are f...
When you want an overrided method to take as argument a subclass of the argument of the overridden method, you usualy accomplish that with generics (as discussed in Template pattern with varying input type in overridden method). An example of that can be seen in my methodA of the class Parent and Child I am wondering i...