instruction
stringlengths
34
36.1k
Goal: 1) huge file read in chunks each 1 MB long, 2) each one gets compressed and written to an another output file. Note: I am limited to .Net 3.5 only. Is there a known pattern how to parallelize file-reading process? Even if I would have to use Thread manually. P.S. I am not asking for code, I am looking for a nice ...
Its a growing practice to run applications into containerized environments which provide an abstraction to the operative system resources. There already are reads about container overhead in certain cases, not all the reads out are critic, there are some where they test no overhead. Like this article regarding i/o. In ...
I've created jquery plugin that is using modern browser's (Node/Element) features. I'm going to publish plugin as npm package. My wish is not to include polyfills code into jquery plugin, bud declare the dependencies on them. Plugin created using Babel. What kind of options to declare those dependencies I have? Just li...
My colleagues and I are in the process of re-architecting our system. The old system is a ASP.NET monolith using TFS for source control. The new system is made up of ASP.NET Core microservices using GitHub for source control and a private NuGet repo in Artifactory. Our first go at it, we put all of our projects in a ...
I know that a memory barrier prevents the re-ordering of instruction from before to after and from after to before the memory barrier, for example if I have the following instructions: instruction 1 instruction 2 instruction 3 memory barrier instruction 4 instruction 5 instruction 6 These instructions can be executed ...
To better demonstrate the difficulties of reading/updating objects in a multithreaded environment, I'm looking for examples for groups of objects with a bidirectional or unidirectional relationship between them such that if one is updated then the other(s) may update also. Notes: updated equals to - the former state o...
I know this question has been asked many times in different forms, but I feel that there is still no definitive answer to it. Some say login is not a valid use case because login does not have any business value, yet others say login is, just like any thing that is part of users expectations, a valid use case. Can we g...
I work for a mid market manufacturing company with around 1700 internal employees and about 7000 external users (employees of our customers). We grew through acquisition which means we have many separate systems that serve that same function for different parts of our business (two ERPs, 3 CRMs, 3 e-commerce applicati...
I have functions like this: foo() { /some/script \ --opt1=val1 \ --opt2=val2 \ --opt3=val3 } This is brittle if I take out the last option, or add any new option at any line. The failures are relatively silent, when I re-source the function, meaning I've run these wrong without noticing. I use t...
Sometimes, I would write if-statements with conditions like it: if(a-b>0){ } but in fact, I can move 'b' from left hand side to right hand side: if(a>b){ } Similar cases like 'a-b!=0','a-b<=0' (not the case like 'a>0') may also applies it. My motivation to do it is: have shorter statement avoid magic number '0' Is ...
Process A take 10 seconds to finish an execution. Process B take 10 seconds to finish an execution. Is it possible to take 5, 8, 15 seconds to finish an execeution if they run stimulately.
Amongst the successful and widely used JITs out there (e.g. JVM JITs, JavaScript JITs, LuaJIT), is there a strong consensus on how the JIT compiler should interface with an assembler? The plausible approaches seem to be an internal assembler (or more generally, any internal generation of machine code), using a library ...
As application evolves, so does the metadata. What are the top considerations for transitioning into a more refined metadata schema? Two example cases, which in my opinion are quite archetypal. Case 1. New metadata is more structured and detailed. For example, Location field goes from free text to Country, City, and th...
Let's say there are two variables a & b, both a & b would have a value between a predefined range. a = x1 to y1 (range) b = x2 to y2 (range) Variable a & b are interdependent, if the value of a is x1 then value of b would be x2 and vice versa. For example. a = 5 to 35 b = 40 to 15 if value of a here is 5 then val...
This question is coming from a frustration when using the Entity Framework and ASP.NET MVC, but I assume it's a general frustration across more frameworks and languages. Lets say we have an object called Invoice. The Invoice has a Recipient. In my object model I have set it up like this: [ForeignKey("Debtor")] ...
I recently faced a problem when I designed the microservices architecture of our new system. To give more context on that, let's suppose that we have two different services. A service is responsible to make payments and the other one B service is responsible to keep track of the orders. We have a use case that we...
I have an enterprise system that is represented by a domain model, part of the requirement that the system should limit access to some of the features based on privileges of the logged in user. Should I put these privileges validation inside my domain model? but there will be a problem that it doesn't know which user i...
Disclaimer: I have limited experience building domain models, this is purely asked out of interest to those who do I have recently stumbled upon the concept of representing data models with ontologies. It seems like it would be a great method for specifying the domain model used by an organisation's software systems. M...
There's an interesting category of objects I've seen in jQuery and some other DOM tree traversal libraries. A traditional way of mutating nodes in a tree would work in some way like this: Elements matches = tree.findAll(condition); for(Element e in matches) { if (condition2(e)) { e.setText("Hello"); } }...
Problem: If running all test cases takes too long, I manually specify a subset of tests to run while developing. But when I finally push to CI, it can happen that I broke some other tests or a functionality that is checked by them. So I underselected tests to run. Similarly, sometimes after making changes I don't know...
Having confidence means Pull Request builds (in Jenkins) will finally allow you to merge the code after a Pull request builds successfully and is reviewed. You're 100% confident that it can go into production. What are the measures(intermediate steps and best practices) a team should follow from the first step of recog...
I have a program that communicates with an API to get information on different organizations, so I have an Organization class and an ApiCall class which are both closely related. As the API I'm using requires different tokens, url endpoints and authentifications to be used depending on the organization I'm trying to ge...
I am working with Martin Fowler's definition as a working base. I have a class called Condition that I am having trouble properly classifying. What makes me think this might be a value object: A given Condition is only valid within a context of a single entity; conditions are never shared, nor addressed independently....
I need to model the status of an object over time. I'm looking for the best way to model this so that concurrent database connections can look at the current status and update the status if the newer status is different. Suppose minimally a record containsobject_id, status_id, start_date. My first approach was to query...
I am pretty confident that this is well-known and solved problem. Suppose there are n uniquely indexed "packages" randomly getting into single entry point like .AcceptPackage(Package package). Packages might be different in term of length, so I can't deterministically compute one's output-file position knowing it's in...
In light of the recent Twitter logging bug, I've been thinking about something with my own web-app: how much information should I log in the event of a 400 or 500? I obviously don't want to be logging sensitive info such as passwords, but I also don't want to be logging to little info. If I did, I'm afraid that users r...
I've run into a debate between a few friends and I. They prefer general exceptions such as ClientErrorException and ServerErrorException with detail as fields of the exception, whereas I prefer making things more specific. For example, I might have a handful of exceptions like: BadRequestException AuthenticationFailur...
We are building an interpreter for a language as part of the requirements in one of our undergraduate course. Part of the project involves writing a lexer and a parser. The parser generates an AST. Obviously, the AST would have nodes. One of the nodes of that AST is the ArithmeticOperationNode. This node will be a node...
I want to implement a lambda service that would provide me random names (generated using patterns, some hardcoded values and so on) by GET request. For name generation I just use the set of prepared morphemes, small words and so on. To create a name I just randomly select part of the word, concat it and return result. ...
This is a use case diagram about the enrollment of students at a university. There are several flaws in it, and I have to find them. I am wondering what is happening when you get to use case "Choose course". Yes, you will also have to "Enroll", but what happens if you choose a course that is not available? You will e...
We offer a platform that provides certain data processing services. All our APIs are accessible via RESTful services. All services require authentication and authorization to work properly (user/client specific data are processed). All authorization works with JWT tokens sent using the Authorization http header. There ...
While educating myself about software architecture and design patterns I’ve noticed that in most cases some language features and design specifics are implied in the explanation. E.g. practically any article or book on that will illustrate the ideas using classes and interfaces. Everything one can easily find on this ...
Consider the following implementation of a static factory pattern... public class Names{ private static final Map<String, Name> NAME_MAP = new HashMap<>(); private final String firstName, lastName, strRep; public static Name getInstance(String firstName, String lastName) throws IllegalArgumentException { /* ...
There's a website where a person should pay to get some service/product. After a person has made a reservation/product by paid for it, I want to allow him to track the progress without having to or register or login. It'll be similar to page on airline website where one can enter their last name and the number of reser...
I have an Employee who can view items . he also can checkout an item independently (regardless of manage items use-case ). The problem is that when an Employee view items he can choose to checkout one. So I think one of the following options is true : the 'extend' relation from view items to checkout an item is not ...
I'm processing a stream of incoming records, for clarity assume they're numbered consecutively 1,2,3....etc. Most of the time the records are arriving slowly enough for me to process every single record. During busy periods they are arriving too fast to all be processed so I need to drop/ignore a proportion of them. I'...
I vaguely remember a quote from, IIRC Kernighan. Something along the lines of: when you find a bug, fix all occurrences of it I think it was either in the "Practice of Programming" or "The C programming language." And, IIRC, it was in the context of logical errors, so did not presume one was not following DRY. Does ...
I am developing a social network app, we chose MongoDB as the storage for our app and mongoose as an ORM. Everything was going smoothly until one dark day the client said he needs to let the users to deactivate their account. Now this seems a simple task but what is making me sick is that the client wants to be like Fa...
The previous guy had worked on local clone of LO(LibreOffice) for TB_LR script support during 2015, and now my job is to get all his commits on his branch to reproduce his work on current LO clone. I was told to cherry-pick his commit one by one, resolve conflicts, build, fix compile and link errors, then repeat the sa...
Like if I want to access an array element in C it's implemented like this: For example: If a = {0, 1, 2, 3} is an array if I want to access index number 2 I will write a[2] and the formula that is implemented internally is (a+2*sizeof(int)) to get the starting address of the index number 2. But this can be done because...
In a Web Application that has 4 layers: UI layer Business layer Data Access layer Data storage layer which is the database One of the requirements is to handle a list of objects with unique key. For the database it is obvious that I need to use a unique key constraint on one column. My understanding to handle duplic...
I have the following code, and I was wondering if I'm optimally iterating through my ranged for loop: struct data_type { int a; int b; }; int main() { // Assume I have initialized a vector storing data_type objects. // The vector is called "vec". for (const data_type& temp: vec) { ...
I have a waypoint class which i use to connect a bunch of other waypoints up. But i also have a special type called a consumer, this is not technically a waypoint but it needs to act like one in that waypoints need to connect to it. So i thought about using an interface due to this has a nature of the consumer so i can...
I see an interview question thats goes like this: Assuming you have an array with numbers 1 to N. Where N is at most 32,000. This array may have duplicates and you do not know what N is. With, 4KB of memory available, how would best print all duplicate elements in this array? If i'm not wrong, printing elements does...
In a website users can register through different social logins ex: facebook, google, github etc in addition to normal email registration. There is one users table to store these users, and in addition is needed a mapping to check if a user comes from 3rd party logins or not. One solution to store the users can be in ...
I have the following class: import Radar class Domain(Radar): URL = 'https://mxtoolbox.com/DNSLookup.aspx' ADDRESS_KEYS = ('mailing_address', 'city_name', 'state_name', 'zip_code', 'country_name') GENERAL_PARAMS = {'format': 'json'} BALANCE_PARAMS = {**Radar.GENERAL_PARAMS, 'account...
Lets say I have a free and paid version of the app. Paid version is a superset of the free version regarding features available to users, meaning paid version will have all the features of the free app plus extra. Is there a pattern to toggle feature availability based on a flag that loads at startup (e.g. free/paid)? ...
I want to create a service that would be running locally (not accessible from the internet) on a given port, then a browser extension will need to access this service. My problem is that I cannot know what port will be available in advance so I would need to pick one more or less randomly and I'll need the extension to...
Im working on the implementation of an IEC 62304 compliant development process in our company and I have a question considering SOUP (Software of unknown Provenance). Our goal is the develop a web application in the future. For this application we will use different open-source libraries on the backend as well as on th...
I am developing a mobile app that depends on some nearly static data. I will gather that data initially from an existing website by doing some HTML parsing. I could now create a database from that data and use this as my backend for the app. Whenever there is new data, I will manually run my parsing program again on t...
I'm currently an intern at a company. For my intermediate report I Received some feedback about displaying the relations between multiple applications. So in my image all 3D rectangles are a deployed application. The database figures are a persistence layer (doesn't need to be a database, could be a file). The feedbac...
I have an interface ICondition which only defines a single method, IsConditionMet This works well as it is the only information the parent entity needs from its conditions. However, there is a situation where a user needs to remove a specific condition from its parent that I am struggling to find a elegant way to imple...
We are using Jenkins extensively. We have several jobs, for building and testing. Our problem is that the current email notifications are not so good, so we are improving that. Basically, we are adding html to the email using information we can get from the pipeline. Now, each job is already complex, with its own scrip...
I'm wondering how best to model in a HATEOAS based API links that allow the client to set parameters. E.g. imagine a search response that returns a list of producst and then refinements that can be performed on them: { "results" : { ... } "refinements" : { "Size" : { "links" : { ...
this Wikipedia article did not address this contingency and i am having trouble finding a definitive IEEE-754 document that addresses this.
This might be an X Y problem, but here's my situation. I've got a QT5 C++ code base whose task it is to allow for the configuration of a "process chain". A "process chain" here means a list of linked elements who execute in sequential order, taking a single input and returning a single output to the next "process ele...
After writing some code, I have a habit of scanning it all over once or twice in order to look for any bugs. This is sometimes a painstaking and tedious process, and it takes up time. After reviewing my code, I then run it through my tests to verify it. Is this a productive way to perform verification? Is it more effic...
I have a fairly simple problem currently but I cannot get a solution, maybe someone here has a good idea. I am working on an open source CMS for artists called Jinya CMS. The whole project originated in a friend of mine needing a new website for her artwork so I started to build her a website fitting her needs. One of ...
In javascript, python, golang or rust usually you have the third party source code available in your development environment such that you can edit it and debug it. I am a beginner in java. What is the best recommended work flow to debug third party library?
Recently, I've been in a few situations where I needed to quickly come up to speed on old code and fix it sufficiently for people to be able to use it again. The code I've worked on tends to have the usual issues (no documentation, no tests, etc.), but compounding this is that I often have absolutely no idea (on a tech...
What kind of exception should I throw if the XML can be parsed, but is not structured in the way expected by the program - wrong tag names etc. Example - Expected <xml> <tag1>blabla</tag1> <tag2> <tag3>blabla </tag3> </tag2> </xml> Example - actual <xml> <tag1>blabla</tag1> <tag2> blabla </tag2> </xml> Is there a...
I encountered code like this below. I was told its fine, and boilerplate is not always better. I agree boilerplate might be bad, but I am not sure about something like this: if (entity.isSomething && wasCheckedBefore(entity.name)) showSomeMessageToUser(entity.name) if (entity.isSomethinElse && wasCheckedBefore...
I sometimes put a link to the site where I copied a chunk of code from in case I forget what it does. Is this a bad practice? Should I copy the explanation from the site instead of linking to it?
i have some experience (mostly as a student) with react and redux, and on the other hand i also have some experience with express, normally for my apps (all of them are really simple) i make a rest api with express, make express interact with mongo or any db im using and then retrieve the data to react. That's kinda al...
A group of friends are tracking the miles per gallon for each of their cars. Each time one of them fills up their gas tank, they record the following in a file: His or her name, The type of car they drove, How many miles driven since they last filled up, How many gallons purchased at this fill up, Date of the fill. The...
For example, sometimes I need to generate a link, but I don't want someone cache the context by url of the same link (e.g.:I don't want Facebook feed dialog to cache the page context), so I need something like this: https://www.facebook.com/dialog/feed?app_id=(my app id)&link=http://(my website)/myContextToShare/(some ...
I have a working web app that I version control using Git - call this v1.0. I learnt a lot during that development including some of the mistakes I made. I now want to re-write parts of the code to follow best (better?!) practices and allow better maintainability. Should I create a new repo or should I clone? (I am usi...
I am in charge of design an application (.NET) that has these features: It´s a desktop app (maybe in the future will be web-based) It´s functionality is to provide users analyzed data retrieved from database. It is done by performing heavy queries generating , graphs and grid-tables to show the information. Users a...
As noted by in the comments by @benjamin-gruenbaum this is called the Boolean trap: Say I have a function like this UpdateRow(var item, bool externalCall); and in my controller, that value for externalCall will always be TRUE. What is the best way to call this function? I usually write UpdateRow(item, true); But I ...
In C#, i can declare an immutable field on a class using readonly. This works for value types, but if its a reference type, there is nothing stopping me calling methods on the object to change its internal state. C# sort of solves this problem by providing concrete types and interfaces that simply dont present a way to...
Our application had a few vulnerabilities detected by AppScan and we had to add server-side validation to catch SQL injection attempts. But my question is, how far do you go in server-side validation? In theory there's no end to how complicated you can make it. Suppose I'm just validating there are no special chars in...
In my company, I'm currently working on a project with some (REST) web services involved. The development is based on the OpenAPI specification and the Swagger tooling. The target platform is an internal cloud platform based on OpenShift. As we make use of an CI/CD pipeline in our software development process (more or...
Context My projects are separated into one assembly with Interfaces, which I call the Core, and another assembly with the implementation, which I call the Implementation. In reality, the namespaces look like this: CompanyName.ProjectName.Core CompanyName.ProjectName The first project has zero business logic in it (Ma...
When i was developing a console app the algorithm was the following steps: first create a temporary directory then call another command that will create an xml file inside the the temporary directory then read that xml file and extract a name from it lastly rename this temp directory to the name extracted from xml ...
I have searched a lot on how to handle timezone in a web app. My application saves all dates as UTC in the database and returns UTC dates in json requests, so javascript proper handle conversions in the timezone of the user device. But I had stuck with the problem of timezone when the user needs a report that is genera...
I have a coupled web application (frontend and api backend served from the same application). It's worked well for our needs but I've been curious about the differences that would go into having a completely decoupled front and backend. I'm specifically wondering about how handling authentication requests would work wi...
I've heard some developers say that if a variable is only referenced one place, to just replace the reference to it with the value assigned to it. I've also heard developers say if a function is only called once, to just put its statements in place of the single call to it. The reasoning typically given is that when r...
If one wishes to upgrade from Node 0.10.48 all the way to the latest LTS version (8.11.2 as of right now) would it be smart to upgrade only to version 0.12.18 first, and then to 4.9.1 and so on? The idea being that every Node upgrade will imply breaking changes and it might be easier to deal with smaller bites of issue...
I've recently watched a few Pluralshigh courses on DDD by Vladimir Khorikov. He was encouraging to create a rich instead of anemic domain models. It all looked very nice in a small test-project, however I still have no idea how to put extensive business logic inside rich domain model. In rich domain model we are suppos...
//------------ let person = { name: 'John Doe', age: 22 } let e = document.getElementById('task-title'); /* Object.getOwnPropertyNames() Returns an array containing the names of all of the given object's own enumerable and non-enumerable properties. */ console.log(typeof person, person); console.log(Object....
I am working on a game, and I have many instances where I have to do something like this: Game.getInstance().getEnergyDropManager().getDrops() Or: this.dimensionSelector.selectDimension(Game.getInstance().getPlayer().getCurrentDimension().getColor()) This gets long to write and not as readable. I could have a class w...
I've asked what is now a deleted-by-Community question on SO on why would someone use javascript's Promise.race, and a high rep user commented this: If you have two services that compute some value you can query them both in parallel and use which ever value is returned first, rather than querying one, waiting for a f...
I was just going through a food delivery application's preferences file where I found that it had a boolean to check if the user has one of its rival's app installed or not. Is it ethical to do so on their part?
Is it a code smell if the methods in my trait refer to parent::methods or to methods that are assumed to be in the utilising class? A random (senseless) example trait foo { public function bar() { return parent::bar() . 'baz'; } public function format($text) { $format = true; ...
I have followed this approach that is described here to implement a simple chat application: https://code.tutsplus.com/tutorials/how-to-create-a-simple-web-based-chat-application--net-5931 I'm writing to a file and reading from the file. I want to implement a feature that saves the chat history when the chat is not act...
This question is about figuring the design of a recursive function that changes the state of a group of elements by processing one of them at a time, with the goal of reaching a desired state. The initial state of the elements is one that does not satisfy the requirements. We try to correct that by processing certain e...
There seem to be many ways to pass a mocked object into a class for unit testing and I am unsure which is the proper approach to take for my PHP application. If I was using Dependency Injection then I could have the dependencies as constructor arguments which I could use to pass mocks in from my tests: class Example { ...
In the following diagram I have a Car which has a Motor. An Audi A6 is a Car which has a Motor of type 2.4 L V6. So both the Car and the Audi have a composition on a motor. However it looks incorrect to have two composition on this diagrams. What is the correct way?
I don't normally use reflection directly while programming in Java. But I do use APIs and frameworks that internally rely on reflection or annotations to provide customization points. A lot of frameworks use annotations to set up dependency injection or do some sort of automated logic wiring on your behalf. This result...
Is it sensible/reasonable to consider using an SQLite database file as a data interchange format? Are there any obvious gothchas or reasons not to do this? Example. Say I have a master SQL Server database and periodically need to SELECT a set of rows from a table, export them into a file, and transfer the file to a rem...
I'm in the middle of creating a web application for a client, and he wants me to integrate magnetic card swipers so his office staff can quickly swipe a card, and load up details for specific patients (each patient is assigned a unique number corresponding to a unique card). In my software, handling the incoming string...
How would you name a class describing a 3d model? 3DModel, this is not a valid identifier ThreeDimensionalModel I do not like this Model to general AnimatedMesh to technical or close to implementation, but maybe ok if there are accessors for face and vertex arrays. But the model is more than the mesh, as it also conta...
In the example below I would like to have an interface that define a data structure schema with some properties, here foo is a static property of the class. The last inherited class override the property to extend its value. We can imagine a more concrete case where I have a Temperature sensor with a static property th...
Some pairs like these: Method and Function Attribute and Property Argument and Parmameter etc. I use all the three pairs interchangeably when I speak to a peer. Do they have a very critical difference or are language specific? I have found this and this on the 3rd pair, both suggests that they are used interchange...
This is a conceptual problem I'm having general difficulty with, and I'd like to look at an example that can hopefully help clarify this: using a map to represent an alterable game world. For simplicity, this map can just be a two dimensional array of ints. I'm approaching this from C# within Unity, if that changes a...
Sorry if the title is confusing, but here's an example to illustrate what I'm trying to accomplish. I would like to create a 'checksum' or ID grouping of similar number sequences, so that when you compare one sequence to another, it can see if they are similar or not. 'Similar' sequences here are sequences that are shi...
This question was tossed as a starting point in a technical interview at a semi-conductor company. I guess there are no right ans - the purpose of this open ended question is to gauge the engineer's depth and comfort level. Question:- design an API which monitors an address and returns when the address contains a spec...
Is this a legit use of getter Lady lady = new Lady(); lady.getWater() = "hot water"; if we suppose getter returns Class Lady { public String getWater() { this.water; }} ?
I am busy implementing a change management process because we have a complex environment, and there is too much oral tradition here. As a starting point, I want to create a list of configuration items. As I understand it, a (software) configuration item is something that upon a change will trigger regeneration of the s...
This is a question that I got asked recently at an interview and was later told it was answering it not well enough which is why didn't get the job offer, interested to see what others would come up with. A company has approximately 5000 employees and it wants to spread information throughout the company. To do this it...