instruction
stringlengths
34
36.1k
Say we set a variable in Python. five = 5 Boom. What I'm wondering is, how is this stored? Does the compiler or interpreter just put it in a variable like so? varname = ["five"] varval = [5] If this is how it is done, where is that stored? It seems like this could go on forever.
Say, I have an entity which has a column "inserted_at". Now I want to add a column "expires_at". It can be in hours, days or months. There're 2 approaches to this: 1) add 2 columns: valid_within_value:int and valid_within_unit_id. Or even a single column: valid_within_value_in_hours:int 2) or add expires_at: datetime ...
I want to capture the connection between an application and the database in a way that is consistent with relationship between entities as defined in the content meta model. We are using the full meta model ref 34-8 i beleive my question relates to the data extension and the Infrastructure consolidation extension. Th...
For example,to create alternate layout in ListView which uses different alternate color : <LinearLayout android:id="@+id/view1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:id="@+id/textview_publish_date" a...
Is overriding a pure virtual function with default arguments good or bad? class Base { public: virtual int func(int i, int j = 10) = 0; }; class Derived : public Base { public: int func(int i, int j = 20) override; };
I'm learning how to work with the MVC pattern, using Laravel, but I have a question. This is an example case, there is a User model and the user can register by itself or an admin can create a new user account using the admin panel, the user should be logged in after the registration and the admin redirected to the adm...
Say you have a virtual machine with the following instruction set. 0 ACC <= [S] Copy address S from memory to ACC 1 ACC => [S] Copy the value of the ACC to the memory address S. 2 ACC + [S] Add the value at memory address S to the ACC value. 3 ACC - [S] Subtract the value at address S from...
Aside from the probable dozens of bugs you can spot in the code below, I'd really like to know what would most people would consider testing in the code below. I have 8 similar exported functions, so I believe it is those that I should be testing. The problem is, they all call the private function sendTokBoxMessage so ...
I have a User Authentication module in my project, that is managing all user information and is regulated with certain granular access rights as Create User, Change User and Delete User. These are obviously meant for administration uses and a regular user will not have those permission sign to. Never the less, as a reg...
I have a class which acts as a Adaptor between an HTTP request and our Application's custom domain request. So every Http request element: URI, headers, content are mapped to our customized domain object elements. Another class DataMapper which performs serialization/deserilaiztion of content. This class is used by th...
I'm working on a project using Python Flask-SQLAlchemy with a model like this: car has components, components can have errors car has a hybrid_property 'broken' which is true when one of its components has errors. Tags can be added and are assigned in a table(car_id, error_id, tag_id) one of the tags will be something ...
Describing the situation I'm working on an application (based on the Spring Framework) using a search index (lucene if that matters) to make content of that application searchable. Documents are added/updated in that index whenever the content of the application is being changed and deleted whenever the corresponding c...
Is this a "overkill" design to store XML data in a relational database? One point is that these web API REST services can later be used by other applications.
I know we should have at least 3 different environments while developing a solution: Development: The programmers are free to change and push changes any time in order to quickly test their code and integrate with other changes, without the fear of breaking anything - this is connected to the TEST databases and servic...
Say I have a bunch of repositories: CustomerRepository(); SalesRepositor(); EmployeeRepository(); etc Say each one of these has a create method e.g.CustomerRepository could be: public void Add(Customer entity) { _dbContext.Set<Customer>().Add(entity); } Say I wanted to use a GUID for all of the entity IDs. Where...
One of our team likes to write code like this (C#): if (_someVar != null) { _someVar = null; } Rather than simply: _someVar = null; I've never used the former as I always assumed it was unnecessary, especially in a language like .Net. Before I get into a debate with them I wanted to know if there is any benefit i...
I've always tried to keep models for direct database interaction only, and keep all the actual logic in the controllers. Usually, a framework or platform provides more flexibility to models and limits the freedom of controllers. Models are usually able to be called from multiple controllers. Models are usually able to...
I'm confronted with a "microservices" architecture consisting of Spring Boot services fronted by a Vaadin Spring Boot application (with an API gateway in between), all written in Java. Communication between the frontend app and the services, and between services, is done using JSON over HTTP (I'm not calling it REST s...
Recently I picked up the habit of typedefing various types within template classes, as is done in the standard library. For example, a container class might look something along the lines of: template<typename T> class custom_container { public: typedef T value_type; typedef value_type* pointer; typedef val...
at my company we are using AWS Cloudformation to manage our infrastructure. The templates are written in JSON. The problem is that the templates are getting bigger by the day 5k Lines. Company policy is to write certain projects in one template (i.e. I'm not able to divide up the code into separate templates). And as a...
A friend has asked me to write a small software program for his own purpose. I haven't started it yet but am thinking about how to distribute it. I mean, there are licensing, encryption and things like that when releasing a software product right? I just want to know, as a beginner, what I should consider when releasin...
I am relatively new to Visual Studio (I've spent most of my life on Linux) and I am fairly befuddled about the Windows build process, especially regarding NuGet. I have a Xamarin PCL solution with several projects (for each implementation), and I removed the packages.config files in each directory and replaced them wit...
I'm working on a program that solves a certain type of systems of equations. The main data objects are Equation, Variable, Solution. Then I have this interface, which represents all things that I want to expose to the UI layer. public interface ISystemSolver { // Configuration int NumberBase { get; set; } b...
E.g. when comparing two integers as follows in a C-like language: if (3 > 2) { // do something } How is the judgement whether 3 is greater than 2 (true) or not (false) made internally?
I have big asp.net web-forms project, I'm using Linq2SQL, I have 1 model per table (same properties as generated classes by Linq2SQL, I add this models to have more controls of fields). For some tables I need multiple ViewModels, for example for Product table I have following models: ProductBaseViewModel contains Id, ...
I am designing a library to wrap an API with Clojure. The API requires user credentials to authenticate user related calls. My first approach was to have functions that do each task the API can do: (defn send-email [credentials email] (call-api credentials :email email)) (defn send-message [credentials message] ...
I've already asked "Dealing with a large interface". I have a further question regarding that situation. It was pointed out to me that I used a lot of getters and setters and so I broke encapsulation. I'm aware of this, but I can't really imagine how I would code this differently. All my getters seem natural to me - th...
I am looking for a solution following best practices to simply periodically validate database entries against some business logic. For instance, I have the database with employees, and another table with incoming calls. My service should periodically run the validation task (or tasks, it might be a lot of business rule...
I'm building for a client's service that allows developers to build client side forms, similar to formspree.io, etc. Basically, developers can set an action to their HTML forms which send the POST data to my service. However, I need a way to authenticate requests. Formspree does it like: <form action="https://formspree...
I have access to a Response object in my python backend for returning HTML pages, etc. I can declare headers, content-type, etc. Instead of re-engineering the Python to use something like Django/Flask (which would allow me to parse JSON data on the backend and stick in right on the page), could I do something like add ...
I am experienced with OOP but I am just starting to use the MVC model. I would like to know what are the recommended practices to use PDO within the model and still keep a high level of abstraction. I have seen on the internet various approaches, the ones I liked the most were: Making the model extends a specialized cl...
An interviewer asked me this question: Given a function f(ar[]) where ar[] is an array of integers, this functions claims to sort ar[] and returns it's sorted version ars[]. Determine if this function works correctly. I approached this question as: First check if the returned array ars[] is actually sorted in e...
In the repository pattern, is it a "bad idea" to call a service method from another service method? In most cases, I naturally end up calling repository methods from my service methods. However, in some cases, calling a service method from another service method seems to make sense because the existing service method n...
JSON supports the following data structures (Java equivalents): Scalar, Array/List, and Map. A Set is not supported out-of-the-box in JSON. I thought about several ways to represent a set in JSON: [1] - As a list However, a list has its own ordering, so the following two lists, ["a", "b"] and ["b", "a"] are not equal a...
2022 Disclaimer: I asked this question when I was novice. It is bad. There are two major mistakes I did : some of the names given are really bad, because in production code, when you name something xyz_controller you expect it to be a MVC's controller, and that was not the case ; it was a service, and a poorly designe...
Let's say I have an interface describing a simple service public interface AccountService { public int getUserId(String userName) throws UserNotFoundException; //... } I've written the UserNotFoundException exception myself and it is specific to this service. Apart from that, anything else that could go wron...
My team is working on a progressive web app. We've been searching for a solution to so that viewers of our app cannot exit the app (it's an in shop app, which we use at our stores that shows content related to the store). I've found several solutions involving putting physical covers over the devices back/home buttons,...
Years ago, when I read The Mythical Man-Month, I found lots of stuff which I already knew from other sources. However, there were also new things in there, despite the book being from 1975. One of them was: The Surgical Team Mills proposes that each segment of a large job be tackled a team, but that the team be organi...
Let's say I've got a REST endpoint which is returning a list of people from some location, which can be referenced by address. GET /people?address=London A response could be: [{ "name":"Jane", "age":72 },{ "name":"John", "age": "23" }, .... But let's say there are people from London UK, but there are also...
I'm making a language, and I'm considering disallowing inheritance. To be clear, this means: class A {} //Valid interface B{} //Valid class A2 extends A {} //Invalid class B2 implements B {} //Valid However, I've also got composition: class C = A; //Simple wrapper type around A class C = A { fun myFunc(){} ...
I am working on adding a feature to a forum where I look for keywords in posts and add links to these keywords. For example, say a user's post includes the phrase "HP Printers". This phrase would be picked up by my regex and then I would link the word to the HP company page. I have this implemented in php so it searche...
In a 2D game, buildings can be upgraded with modules; Those modules can be bought in a shop. The shop is represented by a stereotyped grid of icons, each icon representing a buyable module. When the mouse hovers an icon, the name a description of the associated module appear in a popup. Currently, the modules are model...
I am working on a ReST based service which calls other ReST based services and also deals with Persistence in a database. So a typical call might look like Get some data from the database. Make a call to an external service using a ReSTClient to create a record. Persist the response to the database. Make another ...
This question is about Dynamics CRM but is valid for every system that allows merging entities. Having data related to a contact in multiple external systems, how would you know which contact the data is related to? Using ContactId works until that contact is merged - then the associated data could point to a non-exis...
This is a problem I run into often, and am looking for the best solution. I will have code like this (python): def func(var, opt): if opt: var = var.set_opt(opt) result = var.get_result() if opt: return [r[0] for r in result] # arbitrary else: return result What is a good, gen...
After using SVN for years I'm finally trying to learn Git. The tutorial explains how with Git you commit to your local repo for much of the time. I thought Git was supposed to make continuous integration easier, but if you're committing to a local repo for most of the time, isn't that tantamount to working in isolati...
I have been tasked with developing a java application that includes retrieving one property from a json response from a web server. Normally when I parse json I go with the standard way of creating a pojo model of the json and then using the google gson library to create the object. However this time I feel that it is ...
I'm unclear on how a BLE Beacon and device architecture works. As I understand, there's two "types" of Bluetooth: a classic version which has relatively high battery consumption (I imagine this being the one the user turns on to pair a device, for example), and a Low Energy version (BLE) used for receiving small signal...
I'm learning the java Spring framework. So far, I understood that Spring will make stuff transparent with its configurations so that IoC and Factory are not too complicated to implement... Now I have coded A LOT but I have never thought of organizing my code based on design patterns... My query is that for a basic CRUD...
Like many (most ?) people, we have multiple "common" libraries managing various things (business objects, utilities, external libraries...) for multiple projects (web service, admin/users site, desktop apps...). As it's set up today, each project copies its binaries in an "assemblies" folder one level higher than the p...
When building an Observer pattern, you need to define your events that the are broadcast and observed. Is it better to define an abstract Event class with multiple subclasses for each event, or to define a single enum, where each event is listed in the enum? option 1: public abstract class Event { } public UserInputEv...
I recently ordered a new credit card. I used the price comparison websites to find the best one that met my requirements. I notice that these websites have a lot of validation on the client side. For example please see here: https://www.moneysupermarket.com/credit-cards/search/?goal=CC_ALLCARDS&purpose=AllCards&from=...
So I'm working on a new MVC project and all data access will be through a web service. I want to put the service reference and web service calls in a sort of data layer in a separate class library project. Now my dilemma is since the "entities" (members) will be coming from the web service, the main web project will ne...
I am trying to develop business application with separated backend (persistence, business logic, server side workflows) and frontend (presentation, some business logic) which communicates using REST API/JSON between themselves. This architecture is acknowledged as good one in Is it normal design to completely decouple ...
Note: I am aware of the poor wording of the title but I was unable to come up with a better one. If anyone has a better idea, then please edit the title. I'm trying to recreate a card game but kind of struggling with a problem. Every card in the game has a color (enum) and rank (enum). Some of the cards have some speci...
I have a Python script that lives in my CI pipeline that is responsible for publishing branches and tags, publishing AAR's to our Maven Artifactory, uploading Javadoc, etc. We used to follow a modified version of Git Flow where we would publish off of either a "support/" branch (for Long Term Support of a Minor Product...
Context I am writing a JavaScript library, and I am finding that I don't know what the best way to support object creation. I came up with a list things that I am considering: var obj = Library.newObj('object-type'); var obj = Library.newObj(Library.ObjectType); // Library.ObjectType is an object containing information...
I'm making a game I have a Replay object that represents all the inputs done by a player to finish a level. It looks like that: class Replay { int replayId; int playerId; int levelId; int length; List<Input> inputs; } I want to be able to search and access replays really fast so I'm storing them in...
In English parlance, the term 'event' is used interchangeably to mean either of: a thing which happened at a point in time (strict physics meaning, computer logs etc) a thing which has a known start time and duration (eg a birthday party, municipal event etc) In my domain language I need to distinguish between these ...
So most companies i've been at say they are agile, but really aren't. I understand...it's hard to transition but I was put as the owner of the QA department in a small company and im really trying to get an actual process going. So one thing that HAS worked is actually get a Kanban board system setup for Issue tracking...
I have the task to write the "technical documentation" for a software which I was developing. One reason or another I have never done this before, I do have experience with SRS, but this is something different. I am not sure whether the term technical documentation is the right one in the case (is technical manual bett...
There are solutions in the market such as Spring cloud, Consul etc. which can store and serve env. specific configuration data. But all of these services involve a runtime or boot-time dependency between microservices which consume the configuration and config service itself. Are there any solutions available which ma...
Doctor is end user of this application Doctor opens desktop application on his pc which is not developed by us. We provide interface to desktop application via interop dll's. Desktop application call interface and through it they call our integration exe which includes some services which sits on doctors pc. This inte...
I have several classes that looks like: (some of them have dozens of cases) function __construct($value) { switch ($value){ case "1": $value = Values::One; break; case "2": $value = Values::Two; break; case "3": $value = Values::Thr...
I have two types of objects: M and N, identifiable by a name. Additionally, multiple Ms can be grouped into one or more M-Group (also identifiable by a name), same for Ns. (If it makes your life easier, you can assume that nesting is not allowed, however nesting would be nice.) A Rule consists of multiple Ms and multip...
Background: I'm writing micro controller C code to write an EBML file. EBML is like a binary XML with nested elements, but instead of start and end tags, there is a start ID, length, and then the data. I am writing this into external Flash in a low power application, so I'd like to keep the flash accesses to a minimum....
Background: My company is working with camera systems. In the beginning we built our application around different models/setups of them, which i.e. consisted of different cameras or procedures to acquire and combine the data they acquired. However, we were always limited to having a single active system in our applicat...
Here's the thing: we have a website which has some i18n. Translations are maintained in DB and manually exported into JSON files which are consumed by our SPA one time on load. Now I have the following problem to solve: I want to put those i18n JSON files to some CDN and when someone makes updates in database, I would ...
Suppose I am writing a C++ library that I intend to distribute in binary form, with interfaces from other languages (e.g. Python). The 'easy' approach of just compiling the library and distributing the DLL or Framework does not work well. For it to work you need to compile the library with every supported compiler and ...
Let's say I have the following model: public class Product { public string Id { get; set; } public string Name { get; set; } public string Category { get; set; } public decimal Price { get; set; } } Now, I'd really like to allow people to add to and view my catalog of products. So, I create the...
For ease of use, I will use a build too to automate the various steps required to build my project on a new computer - like installing dependancies and so forth. Once I've got that all automated, how can I test it? I don't have a 2nd machine to try it on. I don't want to mess up my currently-working environment by firs...
Hopefully this question isn't too application-specific; I'm thinking about it with regard to Excel, but I think it applies to any file-based database that includes embedded code. I'm working on an application that removes certain worksheets and code modules from an Excel workbook before it is distributed to a group of ...
The idea of hashes is they get drastically different results for even the smallest change of data. What I am asking for is the opposite of that. An algorithm that will produce proximity hash values for data that is approximately the same. Regardless of where the difference is, to only measure the extent of the differen...
I have a system where lot of messages come and go over network, each message to be sent or received goes through several states, state change occurs based on external events for example if the linked contents of message are downloaded then it changes the state, if its replied then it changes state etc. A message receiv...
I have gone back and forth on this issue several times. On one hand, you could argue, a repository's single responsibility is to manage the persistent state of an entity, and the consuming application is the one that knows whether it will accept a stale value or not in exchange for performance. However, if you are deal...
We are C# shop (and just starting with TFS) with number of different solutions (and there are lot of them) that represent different components, that we deploy on fairly large number of production servers. Currently, component installations are done manually, where developer would go on each server and install/de-instal...
I am developing a javascript (Node.js) desktop program that works with an existing MySQL database. I would like to (eventually) distribute to others with based on SQLite, or MySQL if they need (or possibly some other database). What is a good strategy for writing database agnostic code? I'm baking in switches like the ...
I've got a scenario where I need to compare two JSON files and override one if the values are different. These JSONs also include arrays (i.e. [) My approach is to traverse one JSON to dictionary O(n), and then traverse the second JSON against the dictionary (also O(n)??). There by getting 2O(n) ~ O(n). Am I day dream...
I understand Web API. I understand websites, how they call a web API and all the good stuff. My question is, how do you control the user view in the website consuming the API, based on the API permissions. The goal would be to not have the view in the website if the user is not authorized to preform such action. Not ju...
I asked this at Stack Overflow but seeing as it wasn't so much a programming issue as a theory issue it wasn't well received. I have a program that issues a unique ascending code every time one is requested. All of it is built client side into the console and there are no issues. However I am trying to integrate the p...
I will release a program (not Alpha/Beta/Testing versions). Should I remove the comments in the code? I have some comments that I added to make the code less confusing to me, but since the program will be compiled, and no one should be able to see my code unless they de-compile my program. Should I remove or leave thos...
This is something hat has been rolling in my mind for quite some time now, but I still haven't found a good approach to it. So here's the thing. We have a server application that has quite a few complex use cases which involve a lot of ifs and elses and handling of customer data. I can't go into the exact details here ...
I am a chemical engineer, working in an 'old-world' industry (petroleum refinery). As a computer enthousiast, I have, from the beginning, used code to help me in my daily job. At first, it was VBA macros, increasingly complex. When I figured it was too complicated to solve some issues in VBA, I switched to VB.NET dlls,...
Please see the code below: public IUnitOfWork<PersonEntities> Create(IRepository<PersonDTO> repository) { var context = new PersonEntities(); var unitOfWork = new UnitOfWork(context); repository._dbContext = context; return unitOfWork; } This is part of a...
I know that obviously every language has its own characteristics and implementations, but from a theoretical standing point, viewing OOP as an abstract programming paradigm, does it allows side effects? Does it change the program state? Every object has its own state and an object can change its own state or another ob...
I would have the opinion and good practices in script programming about using print statements to materialize the control flow (I usually use an anchor mark, then the name of the function just entered, and eventually the step number in the control flow). I usually then print crucial variable to check if all is going we...
I'm working on a software project where we have to build three APIs. One for the home banking channel, one for the agency channel and a third for the mobile channel. The agency API is the most complete one as it has all the functionalities .. then a bit smaller Home API and then mobile API. The architects here made a c...
So I understand what an epic is, but since i've never seen "working" agile in the field it's tough to understand "when" things happen in the agile process. To me, I know you gather requirements at the beginning (obviously), but do you FIRST create epics out of these? and then split them up into individual user stories ...
We're trying to write Go in the most possibile idiomatic way, but sometimes we struggle to find which is the best way. For example in our service we're creating/converting a struct from another one: type Foo struct { ID int } type Bar struct { ID int } Is it better to write something like: func convertAtoB(a ...
I read a lot the past few weeks about something that calls the 90% syndrome. Basically, the syndrome describes a project that reaches about 90% completion on schedule, then stalls, finally finishing after about twice the originally projected duration. I found old articles about this problem which describe it and tried ...
When you compile a C source file into an object file, the function names in the object file will be decorated. Each calling convention will have a different decoration. For example, the following __stdcall function: void __stdcall stdcallFunction(int i) { int j = 12345; } Will be decorated like this in the object ...
I've run into several situations where a POJO where whether a field value is meaningful depends on the value of another field. An example, using Lombok (which we try to use to avoid boilerplate): @Data @Builder public class SomePojo { // an enum whose values are DEFAULT_LOCATION, STANDARD_INPUT, FILE private f...
I am new to high-level (Android / Java) application development and I learned of the MVP (Model, View, Presenter) architecture. But it's not clear what the role and design of the Model layer is supposed to be. Most tutorials and blogs about MVP directly discuss and show examples of the View and Presenter layers, but ei...
I'm writing a reminder application where reminders can be shown or not for each day of the week (similar to Google Calendar). So I'd like to store the following in my SQLite database: Monday: True or False Tuesday: True or False etc. for all seven days of the week I could simply store one True/False value for each we...
I am working on a Servlet/JSP project, the website have users and I need to display a user's profile using the notation myDomain.com/Joe instead of myDomain.com/users.jsp?user=Joe. An instance of my case is this current page, the link is displaying myDomain.com/posts/thePost: https://softwareengineering.stackexchange.c...
I'm creating a small social media website, and I'm faced with a dilemma. There are 2 ways I can design my classes and database that I currently know of. Users can make posts on the website by uploading images, videos, and plain text. My initial thought was to make a class for each post type and they inherit from a par...
How to write Readable Comment when we have to deal with IDs? I will explain this with example. +---------------+-----------------+ | permission_id | permission_name | +---------------+-----------------+ | 1 | Add Category | | 2 | Delete Category | | 3 | Add Product | +-------...
When I work on a developer team (3-10 people), I often notice that getting a precise and shared definition of each what each term in code means becomes an issue as the code base grows. After a few monthes, two totally different concepts can use the same name and two same concepts can use synonyms. It hardens a lot the ...
I was reading Akka Persistance documentation and it says that Akka is good for Event Sourcing. Imagine I have a User entity. Each user is defined uniquely with ID and has some properties and some business rules around how they can be altered. Also, some modifications of User properties can have some async side effects,...
In my company, it's common not to do any intermediate build to check how each feature/bugfix branch is merged in dev. There is only daily build, which always elicit a lot of test fails and build errors. I have been told that it's unreasonable to do build for each merge for over 1000 developers. So I searched how CI is ...