instruction
stringlengths
34
36.1k
I have millions of documents(close to 100 million), each document has fields such as skills, hobbies, certification and education. I want to find similarity between each document along with a score. Below is an example of data. skills hobbies certification education Java fishing PMP MS...
Currently working on a project and facing a structure problem. The app I'm developing communicate with hardware my company is building. We want to provide access to third party developer to our hardware but we want to keep data usage by our own (how many time the hardware is turn off/on, how many times the hardware is ...
I've an entity class that the user will construct the object using the setters. This object when passed to another layer, that layer will call the constructChangeDataMap() method to identify the variables that must be updated in another framework. Class Test { private int a; private int b; public int getA() {...
I've recently come across an EF6 application where the logic is driven heavily by the use of IDs, something I hadn't seen before. Once an entity is loaded by EF at the DAL, it is mapped to another near-identical POCO object which sits in the Business Logic layer. Whenever entities are worked with in the Business Logic,...
I am working on a component for an enterprise message queue that consumes a message from a queue and sends it as a text message. The message is picked up by my consumer in JSON format (I do not have the ability to modify how the message is received). { "id":"19ADFASDFGG456SDGE", "body":"Hello World!", "to":...
I spend most of my time analysing data and developing machine learning algorithms with data. As a result, I spend most of my time coding but I never have fixed specifications. Rather, I start with a question I want to answer which leads me to the next question, and so on. For code that won't change, I generally start ...
I have a statement. I know the ups and downs of both Composition and Inheritance, but I am unable to realize that what would be the best option the given scenario. SCENARIO: A Software company is developing a website for a university using a multiple inheritance between classes. The classes include Person, Teacher, Stu...
So I came across an old blog post from Robert Martin (Uncle Bob) that talks about how the Structured Programming discipline convinced programmers to take the GOTO statement out of their code, even when its only implicit like in this example that he gave: if (a>10) b++; else b--; He said that was bad practice becau...
I am writing some user documentation where I need to depict a Microsoft Server Express installed on a computer. (Note: in my user documentation, the idea is that Microsoft Server Express is installed on a computer that is used for typical end-user activities, such as word processing; it is not installed on a computer t...
I'm interested in developing single-paged application and there are few question I need to get clarified before moving on. One of them is customizable theming implementations. As for traditional web applications, we could easily customize a page but since SPA is a bit more complex than that, what would be the best appr...
This is specifically about when to develop and implement code for authentication and authorization. I do not mean things the developer should be aware of such as exploits or using Prepared Statements for SQL Injection, and so on. These should be axiomatic for the developer. What I mean is when in your development cyc...
I am writing an API, in that API I sometimes need to make a call to another, remote API. This remote API needs an authorization token, which it gives if you call an appropriate method (for example, /api/GetAuthToken?user=user&pass=pass, where user and pass are hardcoded or passed to my API via settings file). Then you ...
When applying DDD principles in Ruby, I feel that Active Record pattern ends up polluting the domain model, while I'm not sure how to implement JSON deserialization without breaking encapsulation. The Data Mapper pattern could be an alternative, but I haven't found any satisfactory Ruby implementation that fulfills my...
The intuition of an optional type like Maybe Int is that either there is no Int (thus, there's Nothing there) or that there is some Int; there is something there. It makes sense to me that we call the type constructor for the "negative" case Nothing, since it means exactly that -- that there's no Int there. But why use...
I'm reading the DDD blue book and there is one thing that's pretty unclear to me as of yet and that is how to efficiently perform simple operations on Aggregates that have a lot of child Entities in them. An example Considering I have an Order, (Aggregate Root) that has Line Items. Each Order can only have 1000 Line I...
I'm somewhat new to Java, as I've only been coding in it for almost two years, so every couple months I try to grasp onto a new concept to improve my understanding and coding practices. This is just a question to provide clarification, and get the opinions/best practices from engineers on software architecture. Say I'm...
We needed a persistent storage for API keys and I came up with reading and writing json in plain text and the user thinks it works but is it very ineffecient compared to a relational dbms? I just save the data as json and then edit it manually for this use case. [ { "241103000000056": { "Value"...
I was watching this video to learn about how to use Docker and Jenkins. This guy immediately started talking about concepts I never heard before (well, I'm still in college), which really caught my attention. I found that a Build Server is basically a CI server, which I know about. I couldn't find much about build farm...
Last year I decided to create a web-based SAP Business One extension system consisting of a JavaScript SPA written with Aurelia that communicates with two REST backends written in Go and Java (Dropwizard). However, from October 2016 to the beginning of this months I only worked eight hours a week, as I am studying soft...
In my application I often have the case where the same data needs to be in different format in different places. For example a number has to be sent to a web service in decimal form, but has to be formatted in a specific way for the user to see. public class Prize { float prizeAmount; } A webservice expects the amo...
We have a lot of frontend developers leaving the company because they want to work with react, angular, npm and what not. We use some corporate cms platforms and these javascript platforms don't provide much benefit to us. For frontend we need just css and javascript/jquery. In the last years it has been extremely har...
Lets say I have a resource representing a list of items for a user. Something like this: /users/:userid/item-list [{ id: 1, name: "list item 1", hidden: false, },{ id: 2, name: "list item 2", hidden: true, }] I can hide or show individual items by issuing a PUT or a PATCH request. I can filter ...
I have 2 DTO which have equivalent fields so what I did is I make them implement one interface to treat them same way as a type of interface (avoid duplication) so I put in the interface some Getters and Setters that I need to do the business logic. However, as the fields have differents names but their content is the...
How should I perform updates on nested children of an Aggregate Root? Should I find the child object by traversal of associations and perform the update on it directly, or should I add a method on the Aggregate Root that takes care of it? An example I'm modelling an old project at our company which is a system we use ...
I'm looking to do the following for 1000s of items: 1) get time series data for an item from file 2) calculate mean and standard deviation 3) calculate final calculation using mean and standard deviation 4) add value to list Currently the file is one huge CSV of all items and all dates so there isn't much use multithr...
I was thinking about creating a simple game/simulation where cars drive around in a city as part of a pet project. That made me think how I would simulate these individual cars in a simulated world. How would you cope with the following: The simulated environment has the concept of time. So I guess you need some kind o...
Say I have the concept of a User; a very basic structure in reality. If the business requires that an aspect of the software needs to display all related 'Posts' for example, how should that be modelled? Should there be posts as an attribute on the User entity, meaning that every time a User is required simply to veri...
I have a database table named order. It contains eCommerce orders. Problem is, that's a reserved word in MySQL, and while I can use back-ticks to prevent issues, it's probably a good idea not to use a reserved word. I could name it orders. Problem is, that's a plural. The rest of my tables using the singular naming sch...
Let's say I have an app to manage sporting teams. Potential users have a role of 'coach', 'player', and 'fan'. In many cases they will have to make similar api calls to retrieve info like this: /api/v1/players (retrieve all players on their current team) /api/v1/events (retrieve all events for their current team...
I would like to get an advice on how to tackle such a problem. Currently we're using SQL Server as our database and the whole application is a fat, juicy monolith which we'd like to break down. There's one task that I cannot find a right solution for. Users in our application can purchase certain data sets and based on...
The C# language has two "AND" operators when dealing with Boolean values, & and &&. (Leaving aside the bit-wise operators.) When the left-hand value is False, the difference between these two operators regards the evaluation of the right operand. Consider (false && x) vs (false & x) && means the right hand side must no...
I have a class that I usually end up calling XManager. This class usually acts a dispatcher. Where it will read a config and do what the config says. Assuming that I have the following class structure: -Manger | - Phases | - PhaseX implements Phase { void run(); } | - PhaseY implements Phase { void run(); } ...
It may be inexperience, but in the small projects I've worked on, I've often found it super useful to completely start over. Is this unique to novices or is it a real thing? It obviously doesn't make sense for all projects. If you have a well defined goal, organized documentation and a strong product owner, hopefully...
I am on a team building a SAAS application. Part of the application will send out scheduled reminders to our customer's clients. The project description is asking for the ability for our app to send out those reminder emails using an email address of the customer's choice, preferably their own domain, essentially spoof...
I was reading some questions about TDD here and came up with my own. I understand TDD to be a way of developing or capturing the detailed, internal specification/requirements for code in the course of writing that code. We proceed step by step and add falsifiable propositions to the specification body in the form of te...
Our company have a been embarking on modernizing our IT Systems. There is good deal of progress so far however there are practices i just don't think are not using modern approach. One example is we have an application where their is a rule engine and from time to time the rule changes. The rule engine works by process...
Backstory I am building a daemon that is to be run in the background on systems based on X11. As of right now, the settings are hardcoded, and that obviously needs to change. As such, I plan to create a /home/user/.mydaemonrc Issue Different run configuration files tend to have different syntaxes. .vimrc for example ...
Background: I'm building a desktop app where user ability to develop mods is critical. At its bare bones it is a content generator where the content has many layers, and users can develop their own code to insert/generate content at any/every layer. All these user developed modules would be available to the user on the...
Suppose you have a code base that you have been compiling with warning suppressed, and you have decided to enable compiler warnings and refactor the code so the code compiles cleanly. Many of the code changes will not have any impact on the end functionality of the resulting program. For instance, code like this: int ...
I currently manage a team of 1 backend developers and 2 frontend developers. We usually split tasks into backend and frontend subtasks. Before committing to a scope for an iteration, we assign and estimate the subtasks. Then we make sure that every developer's sum of estimates is less than the length of iteration (20 d...
I’m building a payment system for some ebooks with Reactjs on the frontend, Firebase as hosting and database and cloud functions at the backend side. Customers don’t need an account to buy ebooks so they are not logged in or getting an account. At this point I’ve got a form for their firstname, lastname and email and a...
I am trying to design and implement a solution for the following problem I am facing in one of my projects. There are n (say 30) clients that send me data points of the form {timestamp, object}, where ‘timestamp’ comes in strictly ascending order. I (server) need to listen for them and process the aggregated data from ...
Any Java project that uses my jar, will almost certainly have an additional dependency on another jar, which my jar also contains as a dependancy. Problem is, that other jar has multiple versions. How can I avoid any issues that might arise, in the likely case that your project's version of the 2nd jar is different fr...
I got a proprietary software (something like a DMS system) to process the documents in file system. The software provide very limited API to manipulate the contents of the documents in DMS but it allows to call command line while processing the document. I plan to write a python program to query the database and extrac...
I've decided to write two methods, one providing general functionality, and one doing something more specific and narrow that can be done with the more complex method, though maybe with worse performance than a dedicated implementation. As an example, say that I want to write the methods map and iterate, with the forme...
Researching this topic took me a long time, mainly because of my lack of knowledge of how RSS actually works, I understand that generating RSS is basically generating an XML file with multiple items each of which have its' own title and description..etc.and then we can display these items on the front-end. I am asking ...
I am trying to create a simple app which has 2 activities, which enter text on one activity and then displays it on the title bar if another activity: EditTextActivity: MainActivity: I know the standard way to implement it is to use startActivityForResult: public class EditTextActivity extends AppCompatActivity { ...
I have been looking at examples of good REST APIs, and I read that Rackspace's cloud servers API is often cited in comparison with AWS's RPC-like EC2 API. However, I also saw that their API reboots a server like so: POST /servers/{server_id}/action { "reboot" : { "type" : "HARD" } } While this mak...
Is there something that ratio of the metrics LOC and Sum Cyclomatic Complexity in a project with many modules can talk about? Does it show the logical complexity of a module/project?
I wrote a class ShaderWrapper in C++, that wraps around OpenGL shaders. In the constructor I generate the actually OpenGL shader object, but this method only returns me a handle/id of type int. The actuall shader object is stored somewhere in global space. So my ShaderWrapper objects only have to store one integer each...
Docker has a lot of potential to solve problems in my workplace in a large team (100) of software developers and it's use to solve problems in my workplace. This includes: Having a cluster of Docker Hosts that you can run jobs on Having CI agents run as docker images so you can scale up horizontally as need be (and gu...
We all know De Morgan's Laws !(a && b) === (!a || !b) !(a || b) === (!a && !b) Is there a community consensus around which one of these representations is easier to reason about (and therefore) produces more maintainable code? If there is not, what is this community's opinion?
tldr: I have consumer-like classes that require a number of pieces of information to do their job. It's an "all or nothing" kind of thing: the "producers" providing them with data need to provide all necessary pieces of information or there will be a problem. I want to provide some assertions to make sure everything ...
I'm using dependency injection to supply one of my classes (SomethingManager) with something it needs (SomethingEngine). In the constructor of the SomethingManager I set some properties on SomethingEngine. SomethingManager then exposes a set of methods which wrap up calls to SomethingEngine as well as some small bits ...
I'm working in a team of about 15 people and we're currently in the process of switching from svn to git and establishing a new workflow with git. I decided to use gitflow as our new workflow because it can solve some issues we had with our not-really-existent workflow using svn where everyone just put his/her code int...
C often seems to be taught in terms of contracted examples without much regard to code safety, such as buffer overflows etc. I have often wondered if there are proven, totally safe ways of writing C code, because I have seldom encountered C written to handle all eventualities correctly. And now, reading that even the b...
I have been learning DDD and keep getting stuck at domain separation. I'm currently tackling a "Product Catalog" domain. Now in this domain some products are missing a description or image. I would like to add them if they are missing from outside sources. Currently I have 2 models: "Product" and "RemoteProduct". Remot...
I have implemented a ViewFactory to seperate the generation of View Models from the Controller logic. The ViewFactory implementation has a comprenhensive set of unit tests that cover all paths. As this is a refactor of existing code, I had unit tests which cover the same scenarios, with similar mock setups at the contr...
I am trying to write my first "real" library. In my case it will provide a java/kotlin API for sending network calls to a server. I am a big fan of TDD and would like to code the library in the same way. Normally I would now separate the networking code from the other code to test if the networking class gets called co...
I am considering how to write a repository for a new project. I like the idea of a generic repository like this for the basic CRUD operations: public class Repository<TEntity> : IRepository<TEntity> where TEntity : class, IEntity However, I also read that this is against the spirit of DDD. Therefore as a compromise I...
I am looking at designing an application that has a Microservices back end and a SPA front end. I have some concern about performance, a single CRUD page to populate may require calls to 6 or 7 service endpoints which I can't imagine will be fast. Is is good practice to implement an additional service layer that essen...
Is there a way to apply the Single Responsibility Principle to a function where two things need to occur in a loop in order to not need to iterate twice? For example, suppose I have a function like the following (in pseudo-Python): def process_stuff(list): for item in list: process_one_way(item) pro...
What is the best place to use TransactionScope class? Is it in the business logic or data/repository classes? Example if used in business logic class: using (var scope = new TransactionScope()) { Repository.DoSomething(); Repository.DoSomethingMore(); scope.Complete(); } Example if used in data/repository ...
I'm looking for a strategy to manage my third party dependencies. I don't mean package managers and vendor techs, I mean a process of making decisions about to add a third party lib or to write something by myself. My personal aptitude is "not invented here syndrome" - I always desire to write something from scratch "t...
Situation I have a Desktop Application and a Web Application. I need the 2 to interact with each other. Such though that when a button is clicked on the Web App the Desktop App activates and replies with a form for the Web App to fill in and send back. My biggest concern is doing this as securely as possible with mini...
I'm mainly thinking of x,y coordinates but I guess 3D coordinates and higher also apply. Let's say I'm writing a function to return the center of a rectangle given its width and height. Which is the more logically correct out of center(width, height) { return { x: width / 2, y: height / 2 }; } ...
Which arguments should someone consider when designing a new system and has to either store the name of a person as one field or separately as first/last name? Pros for single field: Simpler UI No ambiguity when trying to enter the name of a person, who has a very long name (often non evident which is the last name / ...
I have an application comprising a bootstrapper executable, a core library and several plugins (shared libraries). The core library is implicitely linked to all components, the plugins get linked/loaded explicitely by the core library. When the plugins functions get called, I pass several objects defined in the core li...
Situation: My app exists as standard and branded version, the branded version has some tiny additional features but most stuff is the same. Right now i have a basic library with popups and visual elements that i can use in every app i make. Then there are several modules (libraries) (features of the app "things one can...
I am developing a retail management app with inventory management, I am facing a logic design problem and I don't really know how to address the problem: How do I reconcile selling item pieces from a pack, for example, I can sell a carton of milk(24 pieces) for 200, and single piece milk for 10. If I have my products i...
Assume we have a function that updates a User's password. Once the 'Update Password' button is clicked, an UpdatePasswordEvent is sent to a topic where 3 other services are subscribed: A service that actually updates the User's password A service that updates the password history of the user A service that sends out a...
Lets say you have a library that licenses with GPL v3. You have two pieces of code, one of them is your "loader" and the other is your real "code". So your "loader" makes a request to a server, and the server gives it a string of the real "code". The "loader" then runs the real "code". You are never given a binary vers...
I've been working on a large distributed system typically with over 10,000 clients living on a single network (LAN) all accessing a central set of API's in the cloud. Not exactly a challenging problem. Where it gets interesting is that each client may be requested to upload a large amount of data anything from a 1 KiB ...
I'm trying to determine the best way to handle a few issues I've come up with on handling images for my site. Background: A small site that houses movie information. I have an admin section to upload multiple movies images per movie. Image files would be hosted on a CDN so access would pretty much be open. References t...
What is the difference and when would you prefer to use Object.defineProperty vs get/set methods in javascript for getters / setters? Ex: class Foo { constructor () { Object.defineProperty(this, 'bar', { get () { return this._bar; }, set (value) { ...
I have to edit other people's JavaScript code. The code usually loads some data from a Web API, generates a table, places it into the HTML page, and attaches some event handlers. Due to the async nature, the program flow is pretty confusing, so I am trying to briefly document it, otherwise each time I get lost trying ...
I have a process running in a Azure WebJob that generate an Excel file containing images and I want to measure the performance of this process in time. This process has the following metrics; The number of images The time took to finish the excel I want to create a graph that shows me how these two metrics variable o...
I have following large object (20KB) cached in memcache - Product : { BasicInfo, //~5KB SellerId, //int CityId, //int AdditionalInfo //~15KB } This is being accessed at multiple places- At some place, only sellerId or cityId is required. At some places, only basicInfo is required. At some places...
I have a base class that has an abstract method; public abstract void DoSomething(ClassA obj); I have several derived classes each implementing this method and each checks obj for null (there is no case in any derived class where this should ever be null)e.g. public override void DoSomething(ClassA obj) { if(obj =...
I have a one-way large ETL pipeline in Scala where I start with protobuf schema A and end up with protobuf schema B. I want to create a many-to-many mapping between the fields of schema A and schema B, where schema B uses a subset of the fields from schema A. The ETL is complex and has lots of transformations where inf...
I am currently developing my own project where I want to use an API to connect to the database on a web server. I understand that when requesting data, you should use GET and when you want to upload data, you should use POST / PUT. The problem occurs when you want to log a user in. You are requesting data, meaning it s...
I generally use auto increment IDs as Primary Keys in databases. I am trying to learn the benefits of using GUIDs. I have read this article: https://betterexplained.com/articles/the-quick-guide-to-guids/ I realise that these GUIDs are used to identify objects at the application level. Are they also stored as the pri...
What programming language first used / invented the 'Safe navigation operator' (?.) ? Unfortunately, the Wikipedia page on this subject does not have information on it and googling yielded no readily available answer.
Writing code, in my opinion, usually involves 2 kinds of code: logical and functional code. While the logical part of the code always differs between every app and its goals, often the functional part doesn't change that much (especially the low level simple functional code) and is often reused a lot in the same projec...
I really hope this is a good place to ask this since the answers might be subjective, but here it my problem: This is probably irrelevant, but I'm working with Python and Django here. I have the Django User and each user is related to a Company. The user can create a company and save different copies of the Company a...
Our situation We have 8 teams and each team produces 8 artifacts (A,B,C, etc). Half of the teams use Git, the rest use clearcase. I would like to have each team utilize Git but this will be a struggle (wish me luck). Each team is responsible for building their own artifacts. These artifacts can be scripts, iso's, jars ...
With one boolean, it is simply 0 and 1, and it's straight-forward to query. With two booleans, it becomes necessary to specify what each number means, ex: 0 F-F 1 F-T 2 T-F 3 T-T Here it's easy to query for all entries where the first boolean is T by foo > 1. But what if it wants all rows where the second boolean is ...
I'm looking at an API scenario where you have an entity, like a phone call, which you can stop once and start once. I was thinking of modelling this as something like the following: { start_time: null | date, end_time: null | date } However, I don't want the client to actually be able to set these fields freely. R...
There are loads of types implementing ActionResult like ViewResult, PartialViewResult, JsonResult, RedirectResult and so on. I have seen two approaches when creating action methods, either always use ActionResult or specify the concrete type which is returned by the action (if possible). What advantage does specifying ...
In different design books I have read that First identify the purpose of class (abstraction). Class should only do one thing (SRP). methods are defined as responsibility of the class. As per my understanding public methods handle the responsibilities of the class which require other class [ie interacting classes] My...
A C# .NET application talks to an external component by calling a known API and marshalling interop structures from the component's response. This is already implemented and working well. However, once versioning comes into the equation, things get a bit more complicated: as the component will evolve over time thus req...
I am working on a feature that will allow the user to configure an email to be sent a time he chooses. Once he has saved this configuration, email will be delivered at his chosen time (or around that time) daily until he/she deactivates that configuration or deletes that. There can be many such configurations having di...
In a DB-first EF6 application, we have a data access layer which handles all the interaction with EF. The objects pulled from the context are EF-generated C# classes, these are then mapped to equivalent POCOs in the business layer. This is a common suggested approach as it decouples the layers. So whilst the applicatio...
Being a complete noob to the actor model way of doing things, I a struggling to understand how I would store transaction history in an Actor Model. In the example from ProtoActor Persistence (https://github.com/AsynkronIT/protoactor-dotnet/blob/dev/examples/Persistence/Persistence/Program.cs) the child actor produces a...
I am relatively (read: completely) new to software development and releasing software; furthermore, I am confused by the terms of the GPL license. My question (which may have been answered many times over without my knowledge) is as follows: if I use a GPL-licensed piece of software to modify my code, without actually ...
Preface I'm having trouble determining if I can use the Qt framework for developing a cross platform desktop app. Situation The app is open source, and the libraries it uses are also open source. So I can provide the source code for the whole app without issue. However, the app will be communicating with hardware that ...
I am more experienced with the Database First approach for Entity Framework. I am currently looking at a Code First project, which returns domain model objects from the repository. Database First Please see the code below, which is a Database First repository method I created: public dbPerson getPersonByID(int personI...
I just finished my compilers course. One of the topics discussed was ways to make compilers more efficient. For example: tail recursion, inlining procedures, strength reduction, removing dead code, constant propagation. Considering that the main reason why C is more efficient than Python is because it doesn't have dyna...
I am writing DDD bounded contexts with some entities using event sourcing for their persistence and other entities using SQL databases. To simplify writing of the entities that use SQL persistence, given everything is controlled via the entity in the domain layer is it common practice to skip the notion of referential ...
We have a config.ini file with methods associated to tables, something like this: [assoc] people = getPeopleTable food = getFoodTable in our main program we instantiate a database object and we call them like this: output = getattr(self.db, 'getTable')(config.get('assoc',table)) and in our database class we have the ...