instruction
stringlengths
34
36.1k
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?
I am posting because, first of all, I want to make sure my understanding on these 3 methodologies is correct. Secondly, I would like some clarification on how they could all fit in together. I see they are approaches used to tackle on different problems, and to me, it seems like they should all complement each other qu...
Is it bad practice to autowire and call a repository from within a mapper class? I have a mapper class that maps a model to an entity for JPA. In order to keep repository calls within my service, it requires additional loops/code in order to get inside the right data, whereas my mapper already loops in through my model...
In ActionScript the URLLoader class that has seven separate events than can occur after you call the load() method. In the HTTPServive classes there are two events, fault and result. In one of the classes I've wrote there is only one event, result. In the result event I have property success that is set to true or fal...
Im using C# as my development language. However I have some confusion over HTTPListener and a web service. Can you please explain what are the differences and advantages and possibly a situation in which you would use either
When developing an application using the MVC pattern, I often find myself adding a new model, a new controller, and a new set of views for the actions in the controller. These changes are pretty atomic, as a new model is no use without changes a new controller (or at least changes to an existing controller). Similarly,...
In my course work I developed the same game for a few operating systems independently. The game can be played both offline (with a bot) and in multiplayer mode (I have a server for that). Now I write documentation, and I cannot choose a term: it is not an application, nor a software suit. I would like to call it an app...
The case in question: The sprint is almost over and one of my Scrum teams did not finish some tasks. (The reason for this is not essential for this question and will be addressed accordingly.) One of them is a classic "90% done" case with a rather large number of story points and will be part of the next sprint - like ...
Currently I am making a console application. Is that right that the Main method of a .net console application is a facade? Is any console application entry method is a facade?
I have an interesting question about string and delimiters. There is a random string str. There are some symbols (OR SEQUENCES OF SYMBOLS) that are predefined and should be temporarily replaced within that string by replace function. The operation should be like the javascript replace Step1: var str1 = str.replace(/...
I am learning the 12 factor rule. I cannot get my head around the difference between storing configuration into environment and Backing service. Also how would u store properties into "Environment"? Ex: I have a configuration for connection to orcale sql, with jdbc. Should I consider it as a config. or a backing servic...
While writing a library for a large project I'm working on at work, an issue came up which required a token to be sent to an email address, and then passed back into the code where it can then be used for further use. My colleague says to just read from STDIN (using Python: code = input("Enter code: ")) and then have a...
I recently started working with a shiny new version of a codebase that uses interfaces all over for... basically everything. I think all of our concrete classes implement interfaces. The problem I've noticed is that the project doesn't appear to code to the interface! Items passed using interfaces are consistently cast...
We got multiple devices that communicate over different protocols (rs232, tcp, http, etc.) and we want be able to send requests from multiple interfaces (as well get responses from each device to multiple interfaces). We are wondering how to properly manage the communication between interface clients and device clients...
I need to make ability to reorder records, storing in DB (I use MS SQL, but seems it's no matter). I see possible 2 solutions: Add Order column. Then if we want to reorder 2 records, we need to change values of Order column for these 2 records. Value of the first record set to the second and vice versa. Problem - we s...
I have an object called SecurityServer. It is created using SecurityServerFactory. I need to serialize SecurityServer to disk/hardware token/ or some other storage. Which is more correct: securityServerInstance.Save() StorageAbstract.SaveServer(securityServerInstance); Both? Neither? Use injection? I have a feeli...
In our TFS (Version 14.102.25423.0) I can click Browse on home page, then under Browse Server, pick my project and hit Navigate. Once inside my project, I see tabs like Home Code Work Build Test RELEASE Question: Sometimes I need to update code with no prior plan - no user stories, test, release plan ...
SDL 2's installation page contains the following comment on static linking: However, we encourage you to not do this for various technical and moral reasons I totally get why they would mention technical reasons, and the document linked in the same paragraph makes some very good points about the advantages of dynam...
I ran into a problem on the project I'm working on right now. It is basically an app that stores a path based on GPS coordinates. The app runs on android an saves the GPS location every second and then sends it to on API. I think if I insert a record for every location saved there will be to many records in the table v...
I have a module object, that consists of several parameters and an algorithm. A parameter consists of a min, max, step, label and value. The module's algorithm is regularly making a calculation based on a value on each the parameters. In my application each of the parameters is represented by a slider on the GUI. I...
Design for Testability is a well-known topic in digital logic. The idea is that it is difficult to exhaustively exercise some hard-to-reach parts of complicated combinational logic unless seams are created, and then test vectors can be injected (where these seams are called "boundary" in electronic design). (Disclaimer...
I'm reading Tanenbaum's Modern Operating Systems and I really can't grasp the following concept: how does a program make a system call? I mean, i got the very basics down (correct me if I'm wrong): the OS is just another program running on the machine (the difference being that it can run in kernel mode having complete...
Since I am new to programming, I just want to understand the format the built-in functions is represented in the documentations. This is the one from python bytearray ([source[, encoding[,errors]]]) Why all the square brackets are terminated at the end? The brackets are nested. There is comma immediately after the sq...
Within a Java shop, we are using Spring MVC, some HTML output and some JSON/Rest output as a service. Our client side is more familiar with jQuery for ajax messaging to the server. We have been able to build Ajax applications but the approach is cumbersome with just jquery and java code. What are some approaches for...
In a PHP CLI software, we are facing serious memory leakage due to a lot of rotten code, both accumulated in our own software and third-party plugins for our software. Currently, the object references look like this: class Server{ // the central singleton object /** @var Level[] */ public $levels; /**...
I want to build an embedded device which will take its current location (in latitude, longitude) and output custom serial data about a number of the nearest few points in a list. Current location and the points holding the custom data are represented by latitude and longitude, although could be projected to another co...
So I'm very comfortable with version control, and just thought to start tracking versions of my bash profile: ~/.bash_profile with the added benefit of being able to share my various aliases and such on GitHub. Assuming that my .bash_profile file needs to stay in my home directory(I can't wrap it in a directory to tra...
So, I have following code: public class CQRSQuestion { public static void main(String[] args) { //received command for algorithm run AlgorithmAR algorithmAR = new AlgorithmAR(111); algorithmAR.runAlgorithm(1,"2"); //after a while we receive another command to actually save algorit...
Here is my use case: I have a two dimensional grid and each grid space is either open or blocked. I know the entire grid beforehand and as I traverse the grid I explore in a radius of 10 units in all directions that are not obstructed by an obstacle. I would like to 100% explore the grid in the shortest amount of time....
I just stumbled over an interesting problem with naming. I am writing automated tests for an Object-Relational mapper. This involves using super-generic classes that exist solely to exercise certain relationships. My test first involved composition: One object held another object which held a collection of objects: Ent...
I want to test the performance of some code snippets in JS using: function perf() { var start = new Date() // the snippet codes var end = new Date() return end - start } then i wrote some sample code: HTML: <section> <button>insert list item</button> <ul></ul> </section> JS: function insertListItem() ...
In the book "Agile Project Management with Kanban," the author Eric Brechner defines "current task estimate" as the sum of pending, active, and done tasks. I do not understand why "done" tasks are included in this metric. Ideas?
I'm trying to do a performance testing with my application under a load balancer. That makes me curious If we test an application under load balancer Is that mean we are testing load balancer or our application? Since our load testing request will send to load balancer first not application. Could you help me clarify t...
I recently needed a function to deep clone an object. I started with the code given as an accepted answer to this question: https://stackoverflow.com/a/728694/1253156 However, our SonarQube complained that the function was too complex, because of the multiple if statements. So I refactored the code to this: function ge...
One of my (open source) hobby projects is a backup tool which makes offline backups of repositories from GitHub, Bitbucket etc. It calls the hosters' API to get a list of repositories, and then it uses Git/Mercurial/whatever to clone/pull the repositories to the local computer. So I have integration tests where I'm cal...
Heres my issue. I have different types of methods which make HTTP requests to a REST api. To keep things clean, I have methods that take different types of request objects as parameters. Example below. Task<IEventResponse> FindEventAsync(IGetEventsRequest data, CancellationToken token); So everytime my controller call...
I have several types of events, for example: abstract class Event { static class KeyPress extends Event { ... } static class KeyRelease extends Event { ... } static class KeyHold extends Event { ... } // ... } And many listeners which respond to some of the above events by registering them in an event ...
During our current build process, we have C code that gets compiled and archived together with some Python code in a tarball. That tarball represents a commit (that can be or not be a release commit). In some of our Jenkins flows, the code is being tested and in some it isn't. But the information regarding to each spec...
I'm currently developing an application which relies on multiple sockets listening for chat messages. When the messages come in, they're passed off to a bot that's associated with their channels. Because of the large number of channels this bot is associated with, it's highly inefficient to create a thread for each bot...
As I understand it, it's generally recommended to package by feature rather than by layer. This promotes higher levels of abstraction and modularity between classes. I can understand how this works in regular non-utility applications where it has clear features (registration, security, etc), but it is hard to apply thi...
I don't understand the difference between an accumulator-based CPU architecture and a register-based CPU architecture. I know x86 is register-based but it has an accumulator-like register. I only ever hear people asking the difference between stack-based and register-based, but not register-based and accumulator-based....
I'm designing a system that like the majority of social related application has posts, people can like the posts and comment on them. And also like the majority of the applications the users can see how many like/comments a post got. The problem is that to show these numbers I would have to count all the likes and comm...
I find myself difficult to remembering the definitions of software engineering terms such as domain layer, entity object, busines logic and etc. I mean when I read a definition of something let say the definition of "business logic" I find many other terms related to it in the definition that I don't know the meaning ...
In my application there are some predefined expression templates that can be used to filter data. One of them is "between x and y". A QA engineer claims that there is a defect in its definition, because "between 100 and 200" gives different results than "between 200 and 100". The expression is internally translated to ...
Is it true that one doesn't "implement a programming language"? I was told that in some comment around here several years ago and I read that actually you do "implement a programming language". The background is that I was trying to check if it is true that python is a "programming language" and not a scripting langua...
Problem: We have to develop a CMS for our sites. The sites are kind of different, but they have common parts. We need to use our external user system and permissions, the menus are different for each of the sites, the forms are posting to a 3rd party system, and we have many other very custom features. Dilemma: Should ...
Let's say I have a form with a black label. I have a button that is supposed to change the label color to red. This functionality has nothing to do with the data layer (the Model), but only with the View. So should the button click event be handled in the Controller or in the View itself?
Given a situation like this: where the position of the triangles is given (it does not need to be calculated by an algorithm). I would like to find clusters of circles around the triangles. Each cluster should contain a given number of circles (in this example every cluster gets 4 circles) and the clusters should be f...
I've read online that MIT is a permissive licence which allows for the code to be used in propriety products, but the licence texts seems to conflict with that, which I'll quote below: Copyright (c) <year> <copyright holders> Permission is hereby granted, free of charge, to any person obtaining a copy of this software...
I'm going through the code of the biggest program I've ever created from scratch and seeing if there are things that I can improve in the design. When I first created the program, I was using Singleton everywhere, but since then I've removed them completely and instead switched over to using Dependency Injection. One t...
All tutorials on GADTs that I've seen (in Haskell, Coq and Idris) use one same exapmle of a well-typed interpreter to show how GADTs can be useful, where you use the type index to encode the type of the term in the object language. What are some other examples and general rules for when we should think of GADT as a sol...
I have tried looking at various design patterns to solve a problem that I am having. I want three objects to be loosely coupled and encapsulated. Object 1: Spring Data Repository: An object for exposing the persistence layer. Object 2: Rest Template Service Object: An object that performs actions on a REST API and co...
I am confused about the difference between the branch and the predicate in a code. Can someone explain the difference with an example?
My client has a process which iterates over a number of actions that may or may not apply to a users portfolio. Quite frequently, processing of an action may give up and jump to the next action or portfolio without the process stopping (i.e. straight through processing). Sometimes the decision which lead to the action ...
I'm trying to union many functions so that they will all run in the same small section of ram but be loaded from elsewhere. I have done this for several sections explicitly with a sections command simmilar to the following: UNION run = RAM { .text:testFunc:testSHA256_Final: {} load = TESTFUNCTIONS .text:testFun...
i'm relatively new to web development and i wanted to understand what does it mean when someone say "they used django for backend and javascript frameworks for front end." please correct me if i'm wrong; my understanding is that they're making all their server side code i.e dealing with database and writing complex bus...
When writing a library/API for the first time I'll usually start by sketching some ideas on a white-board or loose-leaf while thinking about how different parts of the system interact. This usually results in an interface that I'll adhere to when I go to develop some concrete implementation. I'll get half-way through w...
I have a problem with implementing generic user interface interaction. I have different classes that contain data each for particular interface element. So every UserInterfaceElementComponent has data only useful for him - all data inherit from UserInterfaceElementComponentData. For example, UserInterfaceElementRightC...
I am pretty new to angular.js world. I wanted to know best architecture for my solution. I have 4 projects in my solution. First is angular.js app solution which has below structure. Is this correct way? Second project in solution is my webapi. Third project in solution is my data project which has logic for entity fr...
What is the difference between code reuse and software product line engineering? Why is simple code reuse not successful enough?
In a different StackExchange question, I noticed someone using this prototype: void DoSomething<T>(T arg) where T: SomeSpecificReferenceType { //Code.... } Bearing in mind there is only a single type constraint (SomeSpecificReferenceType), what is the difference and advantage of writing it like that, instead of si...
So for my company's deployment pipeline (which is evolving towards CI+CD), I'm being asked to deploy a Jenkins server. As it happens, all the staging and production servers are already being deployed using SaltStack as the orchestration system. Is it worth it to deploy Jenkins using orchestration, for reason of 'reprod...
I want to understand one thing in plain english that how do I actually use an standard MVC design pattern in iOS App. I know about Modal View and Controller and theoretically I know what they do(Controller takes data from Modal and show it to View) However lets say there is an app, which is simply using an api to logi...
I am under the impression that interaction testing (verifying mock invocations) in general should be avoided. When unit testing method postconditions should be asserted instead. However there are cases that interaction testing cannot be avoided. In these rare cases I think interaction testing is allowable. Cases where ...
A recent debate within my team made me wonder. The basic topic is that how much and what shall we cover with functional/integration tests (sure, they are not the same but the example is dummy where it doesn't matter). Let's say you have a "controller" class something like: public class SomeController { @Autowired V...
I am a computer science sophomore doing a data structures and algorithms course. My professor said that insertion sort requires random access, while merge sort does not. According to him, the insertion step in insertion sort requires random access. But can't it be implemented using sequential access in a linked list, g...
The problem I want to solve is the following: Given a set of users, each with a set of interests they can specify themselves, find all the pairs of users that share same interests with a threshold of similarity (e.g 50% similar interests). Furthermore some interest categories should hold higher weight than others (i.e ...
For the SaaS infrastructure I'm building, we need to send transactional emails and run other long-running tasks on a separate job server. I can communicate via a queue, such as AWS' SQS or via a database table. But what exactly should I send from the web server to the worker server via the queue mechanism? Should I s...
At the moment I am developing three scientific software projects (computer vision) in parallel in Python and scratching my head about organization, clean code and easy extensible/to maintain code. One question which I have is whether to keep all three project separate or not? They share similar functions, which I thoug...
I am building a website application using Laravel that will allow me to run gaming tournaments. The site will consist of two types of user, one being the 'admins' that can add/edit results, and the other will be 'users' who can basically view tournament results. I could build this two ways.. A) Have one Laravel app wit...
I'm working on a JEE project, here is the situation: I have an application that puts the maker/checker financial concept. The maker chooses an operation and can modify its values but the checker should approve these changes so they can be registered the problem is that some operation have certain conditions set that ob...
Is it possible that given a MethodInfo object, i can somehow figure out what the MVC registered route would be for that method? I've tried something along the lines of checking if the MethodInfo has a Route attribute, and checking if the class also has a Route attribute, and if they don't have one then just generating ...
What suggestions would you make to write a cookbook to use a distributed database? Does having a tangible end goal enough to distinguish a cookbook from a reference document? What else should I consider when writing a technical cookbook? I'm thinking - create a scenario that needs addressing and walk the reader through...
I am regularly given code with bugs in it and told to fix the bugs without introducing any more. My approach is usually as follows: Identify the bug's issue, e.g. method is returning an empty list and shouldn't be. Write a test that verifies that the returned list is of size==1. Run the test, watching it fail. Write a...
The question is asked in the context of Python, but it is also relevant for any languages with named parameters support. If some entity in my code (e.g. a pubsub implementation) or even a simple function accepts a callback, does it make more sense to call it with positional arguments or with named arguments? def foo(on...
Imagine an application that allows you to add line items to a quote. The end result is like a sales person giving you a printed sheet with information such as name of the business, name of the sales person, and various service line items printed on the quote along with pricing, description, and quantity. To implement ...
I'm currently creating a programming language for fun where the idea is that every function call/new block (if clauses, loops etc) will work in a separate thread. Instead of creating new Threads the standard should be that it does that automatically, and if you want it to run in the main thread you'll have to specify t...
A problem I've come across and never really had a good answer for, is: what is the correct design pattern for creating or returning an object from another object, or multiple objects? Traditionally I've just created a Factory and had the source as a argument: #!/usr/bin/env groovy class Foo { String bar } class Fo...
As an example, if there is a controller that calls a CountryService class and the CountryService class uses a Countries class, should the CountryService return the CountriesClass to the controller? Or should the service have another DTO type that contains information about Countries but is only used by the presentation...
I am new to OOP and how it works. I am having trouble figuring this out. I have a page called general.php which displays a members code, name etc I get the member's code using $_GET['code'] from the url. I get the member's other details from a database using the member's code through my CRUD class. I have a members cl...
Is it true that most of the times source code for Linux programs can be compiled into Mac OS programs and vice versa?
My team is working on a web application using Micro Service Architecture and Angular + Spring MVC. We follow Agile development. For each story, we create few implementation and test tasks. Documenting REST API is the first task to be done in the story. We currently document it in Confluence so that developers and teste...
I read this answer: https://softwareengineering.stackexchange.com/a/234254/173318 please correct my understanding. Business rules refers to list of steps of business in real world (no codes). Business Logic refers to the process of converting the business rules into codes and these bunch/kind of codes addressed as "Bu...
I have written a code generator for my company, that basically has the following workflow: entity xml definition | v gets validated and put into java runtime classes by jaxb | v runtime classes are ...
Suppose the following scenario: A new design for a specific page is required. I create a new branch for that design. I implement the design, and merge back into the master branch. Time goes by and new features is added, and so on... Management wants to revert that page to the old design -_- As per my understanding of...
sorry if the title is a bit messy but I wasn't sure how to form my question. So I have some classes that I've used for a project that I'm looking to making more general so that I can reuse them for other projects. The idea was to move all code that is unique to the current project to a subclass of the original class. T...
This is the first mongo-backed-application I am trying to make beyond tutorials, so I lack imagination when it comes to document schemas. Context: On a dating application, there is an algorithm that identifies matches between users. Currently trying to identify how these matches should be stored. Current schema: Create...
I am reading the book "design patterns: elements of reusable object oriented software. And I am trying to understand the composite pattern. I need help in understanding this paragraph in the case study part of the book Glyphs like Row that can have children should use Child internally instead of accessing ...
I'm new to OOP. Can I say Interface is a set of general behavior that may be have and act uniquely by a set of objects that have in common? And Abstract class has similarity with Interface but it have default method that also can be have and perform by a set of objects? Thanks
I recently checked out Memcached for using it as an in-memory transient database. However, I was wondering why can't we use something like a ConcurrentMap (if I were using Java, for example)or something on the lines of a BST/Java HashSet/C++ std::set. Would there particularly be any disadvantages if I used standard dat...
How would one implement an actor-based concurrent language in ruby? My thought is that only the correct way of creating programs is using actors, but I'm not entirely sure on how this could be done, and how the syntax/grammar could be, but I'm fond of the idea. I will use Ruby together with rdparser and celluloid (for ...
Introduction and context I am refactoring a system that stores energy data (gas/electricity consumption, electricity delivery). Data comes from a sensor that posts the absolute data every 15 minutes in a schema that is subject to change in the future (read: requires document storage). Current situation The raw data is ...
I wrote a small client for a project I'm working on that allows me to connect to various implementations of the application API. The client turned out to be so effortless and versatile that I decided to generalize it and publish it as its own library. I would like some feedback on the design and usefulness of the pat...
What is the better way to organize exception in a Python project? What is the right way to use exception description? For example I have a function that parse email and return some data from it's attachment. It should raise an exception that specify and explain an error in a better way. Options: Use one general except...