instruction
stringlengths
34
36.1k
I am designing a REST API for my mobile clients to interact with our app server (built with Django/django-rest-framework if it makes any difference). There are a number of different objects accessible through the API, some changing frequently (say daily), some almost never changing (on average less than once per month)...
This question takes a Spring Boot service as an example, but it could be any technology. Assuming the following: Environments (dev/QA/prod) are owned by different teams. This means dev must not have access to prod configuration. Configuration (let's say application.properties) is externalized, ie not part of the binar...
I am currently writing a Python program with a main process distributing work to a number of worker threads via separate worker queues per thread. I am now having the problem that the main process needs to know what kind of work a worker thread is doing at a particular moment, since the job allocation depends on this (...
# Introduction I am working on a CMS application in PHP with about 200 classes. The CMS, in general, does the same thing every CMS does: generate sites. I am learning a lot about OOP and design patterns and only recently started learning about how to create maintainable code using Dependency Injection. The issue is tha...
I have an existing project running in the ASP.NET technology. Currently, the entire business logic calculation is happening in the database sProcs (MS SQL Server). And at times, the application becomes slow when it being used by plenty of users during the busy time of the day. Now we want to move out some of the busin...
I am building a PHP CMS system that parses template files and replaces tags with content. Sometimes this content is a HTML, CSS or JS snippet, but it can also be a code include. Most code includes use dependencies, already set in the main scope: the app class, where the start() function resides and all needed domain ob...
I have a method of coding/refactoring that I now automatically do, but I realise I don't know what it's called. If I am making a change, and realise there needs to be a change to some existing code, I always consider if I can do that change first, without any change of behaviour. If I can, I do so, making sure tests pa...
[Summarized answers inserted] When working in a feature branch and I find code that should be refactored that is not related to the branch aside from the fact that it is in the same file I am working in. Should I create a new user story? The consensus is that there should indeed be some sort of new PBI covering the re...
I have a structure that might have 2 more members depending on a preprocessor variable. struct foo { int m1; // ... (other members) #ifdef MORE_MEMBERS int m2; int m3; #endif } In some parts of the code, I need to change some function calls from func(foo.m1) to func(foo.m1, foo.m2, foo.m3). The...
I would like to ask how to convert a method so that it can return any type depending on what happens within it. What I have is the start of an application which will visit a number of webpages (and ultimately perform some tasks on each) before moving on to the next. At the minute I have this: using System; using System...
I am writing an action plan for a personal software project, which I will do research on before and during development. I think the name "action plan" does a decent job describing what it is used for. The research report that will be written after the action plan, will be finished at the same time the application is do...
I would like to create a IQueryable Where method as shown below: public static IQueryable Where(this IQueryable source, string predicate, params object[] values) {} So instead of Where(u => u.Points >= 20) I could pass a string predicate like Where("Points >= param0", 20) What would be involved in accomplishing this t...
Is the disassembly listing generated by a disassembler exactly the same as the assembly code listing that is optionally generated by a compiler during the compilation of C code?
My app has 2 projects: logic.dll and GUI.dll. Currently, its size is 1MB, but the whole app's size is 60MB+ due to the dependency dlls. I've read about QT-LGPL license and know that to keep my app closed-source and commercial posibility without paying license fee, I have to compile it dynamically. My question is: 1> Ca...
Let's say I have a forum application running, and I start building a separate web application with a Python web framework. Both applications use their own MySQL databases, which contain their own respective user account tables. What would be the best approach to keeping the users between the databases in sync? I want t...
For example, a simple program in a simulated environment that waits for user input seems to be doing no work, so I guess it uses CPU only for the time. I'd like to know if computer systems (that don't have any services installed or are disabled ie. logging, updates, etc) could theoretically have constant/zero/minimum ...
Is the strategy in the strategy pattern always an interface? What pattern would it be when the strategy is abstract?
After dealing with C#'s async/await pattern for a while now, I suddenly came to realization that I don't really know how to explain what happens in the following code: async void MyThread() { while (!_quit) { await GetWorkAsync(); } } GetWorkAsync() is assumed to return an awaitable Task which may ...
Is it legal to collect some usage data of a open source library? Let's say, I would like to know Things like These: Name of the assembly, using the library Number of Startups of the assembly, using the library Am I allowed to collect information like these as soon as the .net assembly loads (we're talking about Deskt...
is it bad practice that controller call the methods of domain objects directly instead of service? to explain more: I figure out that in good design controllers call service and service use Domain objects(entities). but sometimes in controller I don't have/need any logic and just need to fetch from db and pass it to vi...
How would you implement a very large file upload functionality with a Django application and S3? In my side job as a photographer, I have several clients for which I have a need to share multi-gigabyte archive (zip, tar) files with that contain the originals as well as the processed images of the event in question. Up...
I am writing a collection that accepts a time parameter, the purpose is that after that specified amount of time have passed the element won't be present in the collection. I want the user of this collection to be able to act when an item is removed from the collection under this circumstance. I have two different ways...
I have the following grammar for logical, relational, and arithmetic expressions which I need to make LL(1) compatible. E -> A | B A -> A op1 T | T T -> T op2 F | F F -> ( A ) | v B -> B lop B2 | B2 B2 -> A rop A | ( B ) op1 -> + | - op2 -> * | / rop -> > | < | == | <= | >= lop -> AND | OR So far I have been able to ...
I'm trying to calculate the sum of 2 bits using basic binary arithmetic and currently, I'm doing this: function Add(bool a, bool b, bool carry) { return { Result: a ^ b ^ carry, Carry: a & b | a & carry | b & carry }; } Is there a way to shorten the expression that calculates the Carry or...
Problem Statement: Alexa has two stacks of non—negative integers, stack A = [a0,a1, . . . ,an_1] and stack B = [b0, b1, . . . ,bm_1] where index 0 denotes the top of the stack. Alexa challenges Nick to play the following game: In each move, Nick can remove one integer from the top of either stack A or stack B. Nick ke...
Is there any generalized rule to decide if applying greedy algorithm on a problem will yield optimal solution or not? For example - some of the popular algorithm problems like the ‘Coin Change’ problem and the 'Traveling Salesman' problem can not be solved optimally from greedy approach.
In a good layered design of an application, where would logic that generates an order number for an order entity sit? The logic will need to lookup and increment either a sequence or a table with these ranges. For example, if i have a service called CreateOrder in OrderService, would this logic sit in another method ...
I have inherited ASP.Net Web form code. Here the business layer is just calling the function of data access layer. For example public string GetCountry(int countryCode) { MyDLSrv obj = new MyDLSrv(); return obj.GetCountry(countryCode); } In short, if you see method signature of function in DAL and BL, it is more o...
I am reading "Revised^5 Report on the Algorithmic Language Scheme," "1.3.1. Primitive, library, and optional features." In particular, implementations must support portable code by providing a syntactic mode that preempts no lexical conventions of this report. I don't understand this passage. Maybe it's because Eng...
I am developing a SOAP server which receives data from many different asynchronous sources (CORBA), updates its internal state and pushes data to its clients. I have a StateManager class which is a Singleton and that encapsulates the server state. I am wondering if it is a good idea to use Command pattern to isolate ac...
I read this in a book: Most of the time, calls to third-party products are entangled throughout the code. But if you really abstracted the idea of a database out—to the point where it simply provides persistence as a service—then you have the flexibility to change horses in midstream. Could you please explain to ...
I am working on a Domain Driven Design project and I have the following problem. I am trying to create a repository that returns a list of objects. The objects have 15 - 20 properties and according to usage I need each time a few of them. Returning full populated objects will cost during population, serialization - des...
I understand what to include in ordinary release notes - there are many questions and answers relating to that. What should I include in the first set of release notes, i.e. for the very first released version? Are release notes needed for the first version?
Here's the problem and how we currently manage this at work. We have a buildout recipe that fetch multiple git repositories. Sometimes, it is necessary to patch a module from a repository that we don't own (public repository). At my previous position in a different company, we used to fork all the public repository and...
I have a tree-like structure of objects. Objects have different types but all of them are inherited from the same base class. Now I want to send some kind of command objects to the nodes. Command object has address of the target node and should be passed through root node and intermediate nodes untill it reaches the ta...
Basically I am calling a Server and expect a JSON response. The complication is when I need to pass the parameter which is in the form of JSON. The initial outcome of my thought process was to have a file that has the JSON input and can be modified according to the individual commands. This approach is cumbersome for ...
I have solved an issue on an open project, on a dedictated fork I've made. After that, I've committed, pushed and merged (pull request) into the main master repo. Now I wish to work on another issue. What's the best way to do this? Should I use the same fork I worked on for previous issue(s)?
I am implementing a validation system which has some constraints, there are category of users let's say 30 and for each category there are number of rules. Actually there are 100 different rules. I have a multimap which maps given user_category_id to list of rule_id's. Constraint 1. The rule should only execute if its ...
I'm developing an application that connects to a database, and I'm using DI/IOC. When running the entire application while developing, I naturally want to avoid hitting the DB. Currently, I have something like this in my composition root (using SimpleInjector): #if DEBUG container.Register<IDbActions, MockDbActions...
I'm trying to improve indoor gps accuracy in ios application. Do people apply such filters to gps data in different apps which track your position? I have 10-20 meters error indoors when using raw data from corelocation so will Kalman Filter have any impact on accuracy?
When designing a REST API, is it common practice to include endpoints that allow you to see if potential resources exists in the database or not (before you eventually fetch them)? For instance, if I want to request product data using a fetch, should I check to see if the potential resource even exists in the database ...
I have been making the mistake creating branches at the User Story Level. See: User Stories != Features. I believe I have been doing it this way because of my poor practice in organizing Features and Epics that are both permanent and really just organizational post to parent the underlying stories (EG. Improve Homepag...
I have a project where I have two classes that both require a database access object that updates the same table. The constraints of the framework and project make it so that I cannot combine these two classes. I have created a case below that shows how the setup is. Class A needs to be able to update and read the reco...
I am developing a multi-tier software solution where I have 1 server, n thin client engines(TCE) and m thin clients at the most basic level. I plan on having many other components for scalability where extra components can be added for congestion etc. but these are the basic components. When I originally designed the ...
We have e-commerce websites for mobile phones. We are building restful api to POST,PUT,DELETE,UPDATE mobile phones. Every mobile phone will have basic features like:- price, manufacturer, year of manufacturing, color, discount. Along with this, most of the mobiles will have images too. Additionally few of these have ma...
I am new to git and trying to understand the best practices about commits and merging. Of course you shouldn't commit buggy changes to the master branch, and from what I understand you should create new branches for features / bug fixes in your project. After testing how merging works, I see that when merging some br...
How should we create new aggregate roots in cqrs architecture? In this example I want to create new aggregate root AR2 that holds reference to first one AR1. I'm creating AR2 using AR1 method as starting point. So far I see few options: Inside method in AR1 createAr2RootOpt1 I could call new AR2() and save this object...
Millions of position data is coming in a system which needs to be stored in a database. The data comes in pipe delimited formats in flat files,on a regular basis say twice a day. And most importantly out of a million records only 5% would have any change. Other records remains same as in earlier feed. Suggest an optima...
If I have a method that receives a value as parameter and stores it in a field for later usage, but then goes on to use that value - why would I use the parameter instead of the field? private RailState _railState; public void UseParameter(RailState railState) { _railState = railState; railState.SetActive(); }...
What is the best practice for specifying which classes are allowed to be stored in a class property? For example if I had a DTO with a property that should allow ClassA, ClassB, ClassC, another property that allows ClassC, ClassD, ClassE, another property that allows ClassA, ClassC, ClassE, how should I define th...
On the net and in books you commonly see examples of the visitor pattern just using "commands" i.e. methods perform an action and have no return type. Is it OK to use this pattern for a query function as well? Take for example this Visitor interface which gets the status description from the specified Status object... ...
Say we have an interrupt that is generated once each time that 1024 bytes of network traffic arrives. Each interrupt takes 3.5 microseconds to process and the network speed is 100Mb.We want the amount of cpu used per second Is it correct that: 1 interrupt 3.5e-6 seconds 3.4e-9 seconds 1.25e7 bytes -----...
Is it considered bad practice to call Close for a database connection within a using block? for example: using (SqlConnection conn = new SqlConnection(sConn)) { cmd.Connection = conn; // do database stuff conn.Close(); }
I have been trying to find a proper way to represent the above data flow (this is just a small case), and I'm not sure if I found a good way to do it. Our current implementation just evaluate all the previous data like: (if user.isMarried && user.age > 23 & ....), so is very hard to maintain. Basically, what I need is...
I must set a bool to be passed down from a controller to a view in my MVC solution as well as do something (as part of an if). I thought, in order to keep the code concise, I could kill two birds with one stone here: if (model.MyBoolean = ([Some condition])) { // Do something } The language permits it, but is this in a...
I'm working on a project in which a user can create tables to save some data. What would be the best way to implememt this? Right now I'm doing it like this: Table 'tables' - contains stuff the user setup like a name. Table 'rows' - contains an id and relation to 'tables'. Tables 'cells' - contains an id, value, positi...
I'm looking for a quick way to split strings containing individual JSON payloads. Currently, I'm using newlines and searching for the newline ASCII character, but I figure if I start using utf-8 this could easily break. Is there any quick single byte character that I would be able to use besides a null terminator that ...
I'm struggling with a DDD concept in designing aggregate roots. I have a Client, which has multiple Projects, Projects have multiple Project assignments, which has multiple Employees. It seems natural to have a ClientRepository, which would manage Project, and not expose a ProjectRepository. After all a Project has to ...
First some background of the problem. I have a transmitter and a receiver, by the way, the transmitter already exists and I have to develop the receiver. The transmitter is constantly transmitting some data and it does so by transmitting once every minute. It transmits just once per channel and it is hopping in a pseud...
So I recently started a new job for a small software company. They've got some old technology which I was aware of during the interview process. However, I've been digging into their code-base, and I'm kind of horrified by what I'm seeing: Swallowed exceptions Servlets generating HTML instead of sending data to JSP f...
Ok. My question is confusing, but what im asking is how could i create my own file with my own encoding representing data. sorta like my own database file with my own encoding ,headers, and info.
We have an existing software product that is being transitioned over to a agile process. New requirements will be captured as user stories, but this has inspired the question around what to do with existing requirements and what the relationship is between user stories and product specification/documentation. I can see...
I have a set of structures in an API for reading data inputs and writing data outputs. For ease of processing, there is an intermediate structure that is used for holding data as it is processed. This intermediate structure is poorly named. Is there a simple, easy to remember name for such a structure that I am over...
So I've read through Short circuit evaluation, is it bad practice?, Is it bad practice to use short-circuit evaluation instead of an if clause? and some other related questions, and I get that it is generally considered bad practice to use short-circuit evaluation for flow control. I'm trying to write warning-free, ROC...
I have a WPF view which contains 2 mutually dependent properties; a change in one might trigger a change in the other. How do I write code that cleanly updates both? More specifically: I have WPF view which makes it possible to export data. That view contains a list of "channels" (that's how I call my data), and for e...
I implement table data gateway on data access layer and transaction script on business. Is it possible to make table data gateway with non static methods and therefore create DAL objects in BL to calls gateway methods? Now I do var result = myGateway.SelectAll(p1, p2, p3); with non-static methods it would be var MyGWO...
You enter the URL in the address string of your browser. It takes long time to appear in the client area. You are bored and type another address instead and click enter. Which page will be rendered in the browser, first or the second? A similar issue raises when you update the outline of your document while typing you...
I'm working for a software development company. The question that I have is whether should we present a user requirements specifications document for the customer/s before we start developing the actual system from scratch?
In 8086, mapping of logical adderss to physical address is done with the help of segmentation. Segment registers : offset, and you get the physical location in a 2^20 byte RAM, even though you have 16 bit registers. Now, my questions are: When logical address are genereted? (When program starts to run? before? are the...
I have just brutally terminated Skype installer, which now gives me error 1603 whenever I try to restart the installaion. This brings be back to the issue that bothers me for a long time: how do you design a reliable installer? It must be reliable because it makes modifications to your system (as opposed to app that wo...
I have a few requirements of the type "the system shall be as modular as possible (to allow distributed installation and reduce cabling)" "to reduce development and maintenance costs, the same hardware shall be used for different subsystem's when possible" I see these as ambigous. Can anyone think of a way of writi...
I have added video calling functionality to my android app using sinch, I was wondering, what kind of technology-infrastructure is needed to do such a thing without using any 3rd party services? Assuming I have a server with a public IP which I can install any server software on, to provide signalling etc., whatever is...
I've seen some serial numbers that have been disclosed on the net and can be used to activate any number of copies of software. How is that possible? Doesn't the software provider check the serial numbers against their database, so that every code can be used limited number of times?
I have a large class consisting of properties that are kind of (import) options. They are stored in one bundle class, so that it's easy to serialize them (or set eg. from environmental variables during the unit tests). It's something like : class MyImportantAppSettings { string Dbo; string User; int BatchSize; ...
Is it possible to produce a web service based on SOAP and on JSON simultaneously? For what I know it seems that only RESTfull services may use JSON
My apologies if my question is not gonna be clear as I do not have experience in the domain of versioning products/projects. And starting: I have a project which has multiple libraries and data sources dependencies and each library depends to another library or data source. For example: <-- L1 <-- L2 <-- DS1 P1 ...
We currently have a complex and inefficient build system consisting of many SVN and Git repos (about 50% each), including one which is a git submodules repo. We also have homemade scripts that manage more or less well the whole thing. A major point of our (closed-source) codebase is that it is tightly coupled, and ever...
I am looking for some logical explanation of how software development fits into a Plan, Build, Run model of an organization. I am struggling to find anything which explains how software development projects fit into this structure. In fact the body of writing appears to be over all very small on PBR. What I do see is...
I'm struggling to really understand memory segmentation. It's the topic of memory segmentation related to segments like heap,stack,code in an object file? Maybe they're for sure, but I still can't find a link and would love if someone can shed light on how the're related if they are. I've read in my book that...
List specific programming concepts that should code adhere to that it will run in parallel. For example, if a block of code does not change shared state, it should be able to be done on another thread. What other such attributes exist? I would imagine there only to be a small number of such concerns by which to evaluat...
I have the following two inheritance chains: BaseQueryBuilder BaseApplication | | | | AppQueryBuilder Application BaseQueryBuilder is an abstract class, which AppQueryBuilder extends by adding additional query builder methods that a...
I am currently writing a ASP.Net web application that has a section for out IT department to manage users. One of the things it will do is give a checkbox list of the active directory security groups and email groups a user can be a member of. I was easily able to work out the code needed to add a user to a group when ...
We're designing a major refactor in my company system's codebase. One of the refactor points, is the (actual) definition of the business logic/domain model. Right now, every repository in the codebase will just fetch every possible piece of data related to the entity, and to "optimize" it, everything is being fetched i...
Today I received a rejection letter from a company where as part of the interview process they gave a a couple days to respond to the following question (paraphrased): Let’s say say you have instances of class UserReview and need to save them somehow, using a storage service of some sort. Please provide pseudo­code,...
I am looking for best practice principle here. As part of my REST Api, I am returning some basic info for a user. Lets say the user can be an "owner" of a company, in which case they have full access to every resource of the company. Or they could have been given delegated access to certain parts of the company. Now I ...
I hope people will indulge me a potentially obvious question. I've worked in a number of organizations that have daily scrum meetings. Some organizations are really strict about only using the scrum for check-in (the "three questions" - what did you do yesterday, what are you doing today, do you have any blockers?) but...
I'm creating a python module at work, and I have a config file with variables that change for dev or prod (i.e. S3 buckets). What's the best way to do this? Right now I have dicts in config with DEV or PROD options, but selecting this every time in the classes seems tedious (i.e. S3_BUCKET[DEV] etc).
I'm working as a programmer in a load cell manufacturing company. We develop our own software for load cell manufacturing and testing purposes. Quality Assurance Department of our company has requested to perform periodical verification and validation tests (once a year) for our released software which has been already...
Games written using OpenGL are relatively easy to port to many platforms, and look and feel the same everywhere implementing their own UI. Web browsers have to solve a very similar problem. So, why don't we have web browsers written using the OpenGL specification? Would not having the same specification for the graphi...
I am working on some Linux kernel drivers for a specific embedded system (NVIDIA Tegra X1). I am using the kernel source provided by NVIDIA (L4T), which has its own default kernel config files. My goal is to make some modifications to NVIDIA's kernel config file to support my new drivers. The complication is that when ...
I could not find any official recommended indentation for the following idiom (straight from http://effbot.org/zone/python-with-statement.htm): with open(path) as f: data = f.read() do something with data or: with open(path) as f: data = f.read() do something with data IMHO, the first version is better at...
Semantic versioning encourages using suffixes to indicate pre-releases: alpha, beta or rc builds. Their purpose is well known and documented. It's also a given that once you create a build or version, its name should not change. All package managers or repositories that I know hence don't support this (NuGet, NPM, Bowe...
I was reading a wiki article about DRM, and I found in the Development paragraph this: Torvalds, as top maintainer of the whole kernel, holds the last word on whether a patch is suitable or not for inclusion in the kernel. So, how is it possible that one man holds the last word whether a patch goes in? In a project o...
I recently completed a black-box refactoring. I am unable to check it in, because I can't work out how to test it. At a high level, I have a class whose initialization involves grabbing values from some class B. If class B is "empty", it generates some sensible defaults. I extracted this part to a method that initiali...
Our company code base still has some code that will create the database, tables, stored procedures and the like.Coding the SQL stored procedures line by line in Java, in string format is a real pain. I was wondering if those out there using alternative methods are willing to give me some pointer in case I'd like to opt...
When designing a RESTful Web Service should the API be designed to work ID for Strings for values passed back and forth between the server? Here's an example: Let's say I have an Employee resource, which has a status and gender attributes. In the database Status and Gender and separate tables and thus separate Domain o...
As an example below, should the isClient() function be part of the Attendee class? import Foundation ///A Node that can be used with the CriteriaEvaluator to determine if clients are present in a Meeting. class ClientCriteria : Node { /** Calculates a score from 0..1 to identify the likelihood that a list of Attend...
We have 3 different systems which exchanges data on a regular basis. There are Some standard mappings between fields (Ex: field Category= A or B depending on input). Indirect mappings between fields. (Ex: field Prio= A or B depending on input along severity) Filling Mandatory fields (Ex: Summary) Standard Workflows....
I have a table, each row can spawn a model with additional information. Is there a best practice for displaying tons of information like this? I've considered the following options: Save all information as JSON and leave in html element for JS to populate the modal with when clicked. Render a separate modal for each t...
I sometimes see the term "Gating" or "Gating bugs" in scrum development. I felt like it is something needs to be fixed before the next sprint. Am I right?