instruction stringlengths 34 36.1k |
|---|
I have an app which accepts two parameters: payment received and cost. It then calculates change denominations.
It is an MVP app, which calls a WCF web service, which accesses a Domain Layer DLL.
Say a user enters £1 for the payment received and £2 for the cost. Clearly this is wrong (there is not enough money). I ... |
In the SETUP section of my README, should I just link to instructions for each dependency like this:
STEPS
install Appium (guide)
install XYZ (guide)
Or should I reproduce all their instructions here, instead of the links?
Their instructions are out of date. For example, Appium tells you to install Ruby 2.1.1, and t... |
I'm working in C# and doing some communication between 2 apps I'm writing. I have come to like the Web API and JSON. Now I am at the point where I am writing a routine to send a record between the two servers that includes some text data and a file.
According to the internet I am supposed to use a multipart/form-data ... |
I am currently working a School Management project using Spring stack, Kotlin as programming language and Neo4j for storage solution.
Here is the scenario, I am creating a Class entry in the DB. Lets assume the properties of the Class entity object are Name: Nine, Section: A, Shift: Morning. When I am going to save in... |
Writing some services on a system I'm working on has raised some questions as to how to provide the data formatted for the client (views or mobile app). Basically, my doubt is born whenever I need to provide grouped data or data that needs to be changed after the query.
I will use as an example a Has Many Through relat... |
I understand if 2 classes have circular dependency, eg:
public class MyWindow{
public MyWindow(){
new MyDialog(this);
}
public onDialogResponse(int option){
}
}
public class MyDialog{
MyWindow myWindow;
public MyDialog(MyWindow myWindow){
this.myWindow=myWindow;
}
publ... |
For 3 months, I've been working on a Web Project using PHP to create a platform to handle remote lights and sensors. I'm currently working almost alone on it, but we will be 2 on it in the next months.
As we are developping our business, we decided to try to work using an agile-like way of working. Nearly each month, ... |
I am not able to understand this basic recursion example.
When I executed this code. The output was 43210.
Should not the output be 44444, as the value of num is updated to 4 to the latest recursive call or how is the value of num getting changed?
Please explain, any help is appreciated.
|
In my small team we write applications that run as a Jenkins job and using the SOAP API of our Bug Tracker, our ALM software. They are accessed with Java however I think developers using other languages are facing the same problem like me as I regard it as pretty common.
My problem
Let's say I have a java class BugTr... |
I've made the code below work and it is mostly non-blocking except where the process.start code is.
However, my question is, in my winforms application is this the best way to implement the use of async/await to prevent blocking?
Having googled a fair bit to get this far, I'm not terribly clear on what better way I cou... |
I am using entity framework to get a IEnumerable<CustomersEntity>, and I need to cast this to a IEnumerable<CustomerBO> to display it in some view. I know how to do cast a IEnumerable<T1> to a IEnumerable<T2>; but in this case, who will be in charge of it ? I thought CustomerBO could do it, but is it correct for an obj... |
I have the following tree currently to be implemented in Java.
My problems are the following:
How can I go about addressing the fact Admin needs to have all tier 4
logic from both branches of the tree since I cannot inherit all 5 of
said classes?
How can I refactor the tree to reflect the fact that outside tier 4
an... |
I am getting files on HDFS and I have a legacy java app which checks for new files every 15 mins, does some transformations and write them to some remote server.
Now, I am facing scaling issue with this APP. I don't want to rewrite this complex app, I am thinking about adding some files distribution mechanism and runni... |
I created a table of values that return time t in seconds, given an ambient temperature. If one were to plot these values, it might look similar to a quadratic or log. I could just use the look up table, and if the value I need is between 2 points, I could interpolate.
Using this table of data points, what is the proce... |
We have an in house developed and maintained Windows service written in C#. Other people and teams write plugins for this service.
Right now, the git repo for this service includes 3 'demo' apps that are meant to show plugin authors how to write plugins that interact with this service.
My job right now is to work on t... |
I'm trying to improve this document parser and there is one main loop that goes over all of the main elements (let's call them Nodes). Each step (Step) can either Consume or Ignore the Node that it is passed. A Step can also be greedy and consume more than the single Node than was passed to it. A Step could restrict it... |
During the daily standup meeting in the middle of a sprint, the de facto project manager/scrum master usually asks developers some version of:
"So when will this be done by?"
"So can you commit do having this task done by 4pm today?"
"How many hours do you have left on this subtask?"
This is frankly very annoying and... |
As per the microservice architecure, there should be one codebase per microservice with no shared API whatsoever. This enforces a high level of decoupling and every microservice is bounded within its own context.
But these microservices, over time, will communicate with each other. Service A talks to Service B and Serv... |
Our process is that developers create subtasks for user stories to track their work on that particular user story on the scrum board.
Good so far.
However, we have a de facto project manager attempting to "do agile" and take on the scrum master role. During the daily standup, he gets visibly upset when a subtask sits ... |
It always seemed normal to me that the larger a company gets the less amount of work is put by its employees into making the company profitable.
There are obviously no clear marks for this, but I don't think anyone will argue that joe working for IBM has the interested of IBM in mind the same way bil, co-founder of St... |
In software deployment, what is the difference between QUALIF, UAT, PREPROD and PROD?
|
If you look at the source code of a website such as Facebook, you'll see many classes as such:
<div class="_cy6 _2s24"><div class="_4kny"><div class="uiToggle _8-a _1kj2 _4d1i _-57 _5-sk" id="u_0_8"><a data-hover="tooltip" data-tooltip-content="Quick Help" data-onclick="[["HelpLiteFlyoutBootloader","load... |
Context
When implementing a class, there's a distinction between fields that are there because they are part of what the object is and fields that are there because they are needed to implement the object.
For example, if you are implementing an ArrayList, you will have an array that isn't part of what an ArrayList is ... |
I saw a project manager recently stand up at an Bank's internal staff meeting and say:
We're running this system migration not using an agile methodology. We know the requirements up front so agile isn't required.
I've worked on a few migration projects. The challenge is that you discover requirements along the way ... |
I have 5 forms which in hindsight should have an ancestor descended from Form. Unfortunately, the common elements of the forms is a splitContainer and a listbox in one of the containers. Each form has it's own collection of panels in the other half of the splitter.
Is there any way to fix this problem without having ... |
When designing an activity-based authorization system, how should additional conditional checks be handled?
For example, I have the following authority:
VIEW_COMPANY_TRANSACTIONS
which allows the user to hit the endpoint
GET /company/{companyName}/transactions
However, what if my authority VIEW_COMPANY_TRANSACTIONS ... |
I have posts table:
id (int) index
uid (int)
text (text)
created (int)
is_deleted (tinyint)
and a table to store post stats:
post_id (int) index
comments (int)
shares (int)
views (int)
Now when I fetch post, most of the time I also fetch the stats. The reason I created another table was because these stats update fre... |
Say I have a C# app, which is layered. I want to test the domain layer independently of other layers. Therefore I have created a Domain Layer project with three classes e.g. Person, Order and OrderItem (hypothetical).
I have used Inversion of Control (Castle Windosr) so I also have a whole load of other classes:
Pers... |
In a chat application there may be multiple types of incoming messages to be handled. For example, I have messages of these types: text, link, image, and video. Text and link are handled the same way, but image and video require the file to be downloaded from different server.
Also each message may need to be deleted.... |
I have been reading a blog where the author has mentioned the below two styles of coding.
Min and Max 1
int min = Integer.MAX_VALUE;
int max = Integer.MIN_VALUE;
for (int x : array) {
if (x < min) min = X;
if (x > max) max = X;
}
Min and Max 2
int min = Integer.MAX_VALUE;
int max = Integer.MIN_VALUE;
for (int x : arr... |
I'm using C++ concepts to ask the question because that's where it came up, but I'm asking about any language feature or tool that would somehow support this.
Suppose I have a class that's a light wrapper around a list of values. These values are expensive to compute, so they're computed as they're asked for. The objec... |
I'm reading "Learning Python" and have come across the following:
User-defined exceptions can also signal nonerror conditions. For
instance, a search routine can be coded to raise an exception when a
match is found instead of returning a status flag for the caller to
interpret. In the following, the try/except/e... |
My background is in mechanical engineering, so please forgive my ignorance to this area.
I really enjoy programming and software development. Also, I recently took a free online Machine Learning (ML) class, which I highly recommend, taught by Stanford professor Andrew Ng. Link here.
I've heard this professor say that i... |
Two of the OOP metrics, Coupling Between Object classes (CBO) and Polymorphism Factor (PF) both measure coupling.
Is there an instance where of them has a higher coupling while another has a lower coupling? Is interface inheritance one such situation?
Also, how does each of them measure coupling?
|
I'm developing a open source application that have a client and server side. The first version only have as client tvOS, and is being written with Swift.
Now, I'm writing the network system for my client. My client need to make requests for the API and manager websocket with the server.
What would the goods practices a... |
I've always used JSON files for configuration of my applications. I started using them from when I coded a lot of Java, and now I'm working mainly on server-side and data science Python development and am not sure if JSON is the right way to go any more.
I've seen Celery use actual Python files for configuration. Initi... |
As the title says: How do you properly test and benchmark different implementations of mutexes in c++?
Essentially I wrote my own std::mutex like class for a project running on a 2 core, armv7 with the aim to minimize the overhead in the uncontested case. Now I'm considering using said mutex in more places and also dif... |
I have a program that can get code from a user as input (This question is language-agnostic, though I am primarily interested in answers for Java and Python). Usually, this code is going to be useful, but I don't have a guarantee that the user isn't making a mistake, or even deliberately giving malicious code.
I want t... |
It seems the general consensus for unit testing classes is to test your object through its public interface only. So if you wanted to test the removeElement method on a LinkedList class you'd need to call addElement, then removeElement, and lastly containsElement to assert the element was removed.
This is brittle beca... |
I'm developing a C-based software in which I want to use a Model-View-Controller approach, and while I think I quite got into the style's rules, I don't really understand where should I place the methods about connecting to the server (I'm developing a client). One of the cool things of MVC is unlinking the actual logi... |
This seems to be a variation on the Travelling Salesman problem, and I started (as
far as some reading at least) going down that route to solve it, but the ordering restrictions are confusing me a bit.
I have a map with an arbitrary number of destinations on it.
An agent is given a set of trade routes.
Each individu... |
I am developing a library from scratch. If I license it under GNU GPL (or a similar license), which conditions everyone to disclose the source code, does the condition apply to my other projects?
Say I will create an android app that uses the aforementioned GPL library. Do I need to publish it under GPL aswell? Does it... |
I'm working on an API and am trying to report back to the consumers certain errors (e.g. input errors, errors that occur during the processing of their requests, etc.). My API returns an array of errors (and warnings, and notices).
I'm starting to see a couple of problems:
I'm not completely DRY. A number of the error... |
I have an example about design patterns that demonstrates the adapter pattern.
But I see casting to derived class here. That is not very good.
If I meet such code in my practice, what is the best way to refactor it?
Or what principles should I follow to avoid such situation?
public class SqlServerLogSaverAdapter : ILog... |
I'm programming with the embedded device running Linux, where memory is less, I just have 64MB flash only. I planned to use queues for the thread communication.
In which I came across with using POSIX queue or just use the simple queue.
Actually, my need is I don't want the queue to be priority driven. I want to know... |
I have two browser clients: A and B. They communicate through a signalling server Server.
A has a clientside heartbeat that signals its ClientState to other clients. ClientState can be one of the following:
StateFoo
StateBar
Sometimes, B wants to change the state of A. It maintains a representation of A locally. ... |
I am writing software that makes use of a neural net.
What makes my network special as compared to others, is the way I train them.
Its non standard, its something that I don't want to give away to another company. So I've been thinking about how to protect myself against miss-use / stealing of my neural net training ... |
For example, I have a Selenium WebDriver and as part of my initialization I would like to check if I am able to instantiate it and start up browser.
I can't come up with a proper name. Is there any common-agreed practice, like naming methods with side effects to be verbs? Should it be one of these options, or something... |
There's a unix shell command (udevadm info -q path -n /dev/ttyUSB2) that I want to call from a C program. With probably about a week of struggle, I could re-implement it myself, but I don't want to do that.
Is it widely accepted good practice for me to just call popen("my_command", "r");, or will that introduce unacce... |
I want to know if it's faster and more efficient to store and access objects in a nested dictionary Dictionary<string, Dictionary<string, int>> VS List<Object>. Though adding objects in a nested dictionary requires writing more code by checking keys, what could be the other differences that are important to consider?
E... |
In a book that deals with mutually orthogonal latin squares, there is an example of implementation of a generator.
The part of the code is as follows:
for (int k = 1; k <= numberOfLevels; k++) {
for (int i = 1; i <= size; i++) {
for (int j = 1; j <= size; j++) {
squareArray[k - 1][i - 1,j - 1] =... |
As part of a hobby project, I needed a rectangular Matrix object to maintain state of a grid. At first, the implementation seemed trivial and unworthy of further discussion: (I haven't included all the code, only the relevant code)
template<typename T>
class Matrix {
uint64_t rows, columns;
std::vector<T> _data... |
Forgive me if this is a truly naive question, I can't find an answer anywhere (which makes me think it is maybe silly and naive).
If I am to hold a reference to an aggregate inside another, I of course use the Uuid of that other aggregate. My question is how should I instantiate that object?
Being that it is a value ob... |
Does 1.0.0 represent the first patch of the first minor version of the second major version? Or does it represent the first major version, with no minor or patch versions? I've always assumed it to be the latter, and it seems so have many others. I typically see new packages in various package management systems start ... |
I am wondering whether this is the correct way to handle my situation when packaging-by-feature. Use the following project structure as an example:
com.foobar.web.Bootstrap.java
com.foobar.web.TcpServer.java
com.foobar.web.RequestHandler.java
Everything part of the web feature is in the web package - good so far. As a... |
I have a system that acts like a message hub. It normalizes data and stores it to be picked up by a different system. Currently I convert my object model into tables and columns for storage. I came to realize that a good deal of the data is being stored in columns and tables but its not really doing anything useful ... |
I'm learning about HATEOAS and I noticed that every implementation always seems to implement a self-relationship first. For example a common response object might look like
{
title: "The Wonderful Wizard of Oz",
author: "L. Frank Baum"
links: [
{
rel: "self",
href: "www.foo.com/book/1234"
},
... |
I am currently working on a voxel (Minecraft-like) engine in C++. Almost all of the code (ie. world generation, rendering, user input) needs to access data about the block types. To accomplish this, I created a BlockRegistry class with member functions to register and access BlockType instances. Each BlockType instance... |
I wanna know what is the importance of multithreading in network applications? I have researched for a while but I didn't find references related to this specific topic.
|
In this question on the Aviation site, one of the reasons for the long development time of the F-35 was quoted as being Software. 8 million lines of code. Development from contract to in-service took 20 years, the last 10 years of which were mainly for systems since the first production aircraft was delivered in 2006. ... |
I have heard a lot of times when other developers use that phrase to "advertise" some patterns or developing best practices. Most of the time this phrase is used when you are talking about benefits of functional programming.
The phrase "Easy to reason about" has been used as it is, without any explanation or code sampl... |
For a couple of months now Im writing a interpeter / compiler for a programming language in C#.
I have encountered some issues recently which make the code feel incorrectly written
Classes change a main state
Classes are not really testable
Classes are hardly maintainable
Firstly
Im looking for a good structure for t... |
To be honest, I'm a student here, but I have seen many questions from teachers asking for ways to explain, and I have not found one for the MVP and MVC patterns.
Model–view–presenter
Model–view–controller
My problem is, that I have studied these pages, I have written many tutorials and followed examples and even work... |
I have a mission critical Backbone application built before AMD and CommonJS were widely used. This application makes heavy use of the Object Namespacing pattern, so that that all the views, controllers, etc. are nested deeply under a single ParentObject, e.g. ParentObject.Views.Feature.TableView. Continuing with this ... |
Lets imagine the following scenario:
I have a system that is on web, you can add data update it etc. Then
you have a mobile phone which obtains the data from server.
How will I keep track of the latest versions? In one word how will the device know when to sync?
The app needs to be offline, and when it connects t... |
I am working on implementing an API interface for my project.
As i know, there are different forms to make pagination through the results, like the following:
https://example.com/api/purchaseorders?page=2&pagesize=25
But, i see many APIs like google use a different approach, in which they use a "pageToken" to let th... |
Background
I'm trying to design a layer/component in my distributed application that will communicate between component A and component B.
Right now, this "communication" is accomplished by replicating an entire database from the server where component A lives over to component B. But this design has proved to be ver... |
I'm using Azure file storage and there was a huge number of files uploaded. A single file will be 250kb in size and there will be 7000 files in a directory.
So when the user request I need to get the data from 100 files in a single call.
At first, I was accessing the files using native file IO methods after mounting th... |
I am publishing an Android app to the Google Play Store soon and have some questions regarding the use of libraries licensed under Apache 2.0. I am also releasing the source code on GitHub. I am only using these libraries, not modifying them. To me, these are two separate concerns so I will address them separately.
The... |
The situation
Let's imagine a couple of developers start LittleProject™ inside of a company. No Unit Testing, no Jenkins, no Docker, a single development environment... "why would you want more? It would be overkill."
The project is successful and grows bigger and bigger. More developers are added. A couple of testers ... |
I have been searching for an efficient algorithm to merge overlapping intervals on a dynamic array of intervals. For example, (start time, end time) wise,
[(1, 2), (4, 8), (3, 10)]
becomes
[(1, 2), (3, 10)]
after merging because (4, 8) and (3, 10) are overlapped. Overlapping means any part of the two intervals share... |
so I'm trying to understand how microservices are set up in a language agnostic manner for purely experimental purposes.
For the sake of having a more concrete example, how would a microservice architecture work in a Node.js CRUD server, does a simple CRUD server even benefit from microservices?
What are the kinds of t... |
I understand the difference between a rich domain model and an anemic domain model.
An anemic domain model contains classes with state only i.e. the behaviour is contained in application services. I recently asked a few questions about rich domain models. I notice that the answerers usually (well always) appear to s... |
I'm building a simple shopping cart using Angular and ASP.NET Core with. There is no login require and user can always checkout and make payment as a guest. The front end would be built with Angular, with simple 3 dynamic components - Shop > Checkout > Payment path in a single path. I'm presuming I will be relying on A... |
I have micro service architecture application. One of the services contains all user related information. Another service contains a set of business objects. The Angular UI calls rest APIs of user-service and business-service to perform operations like user management, business management. The tables in the business-se... |
Whenever I was required to build a project, I always managed to build it, not beforehand devising a plan or design, but after first writing a class that was needed, fleshing out the entire project, building from the bottom-up. Now I know this is not the proper way to create software, but it is not easy for me to wrap m... |
I’m working on a medium-sized project. One of the parts has to do with account creation.
I went with a RESTful API design at first, but I’m now having second thought. Persistent data are saved in MongoDB.
So to create an user, one API request is required to the backend. After creating the account, another API call to ... |
For anyone who uses callbacks, how do I approach it when the method is an asynchronous setter?
Here's an example
class API
{
constructor()
{
this.token = null;
}
refreshToken(callback)
{
request("http://api.com/token", (token) => {
this.token = token;
callback(token);
});
}
}
What ... |
I have some data (list of parameters) that should be shared across the backend and the frontend. The changes are really infrequent, and changes usually mean a redeploy. Currently, it is stored in the DB, some tables have foreign keys on it. By extending the functionality we had to keep adding new and new properties on ... |
If I have two use cases: Send Email, and View Contact Page. And Send Email includes View Contact Page. Do I still need to use association to connect my actor(user) with Send Email if I want to show that he can send emails? Or It is enough to connect actor with View Contact Page with association?
Here how it looks like... |
I'm designing a system at the moment using MVC (with Laravel, if that matters) and I'm trying to decide how best to architect a part of it.
An an analogy, you could look at it like this:
There's blog posts, and each blog post can have three different types of comments. Each type of comment is completely different from ... |
There is that @Deprecated annotation which suits well for Java libraries.
A minor release change would not break an existing code if a deprecated library method remains. The library compilation will not report deprecated code use warnings because the library itself does not call its own deprecated methods.
But what if ... |
My organization is investing time in writing the wrong kinds of tests (unit tests that are tied far too heavily to the implementation, are very time consuming to create, and often make the system harder to change). Also, context is often thrown away and tests are skewed to improve coverage metrics.
The same assumption... |
The Existing Code
I have a C# project with about 45000 lines of code. It has a utility/helper class which contains static methods which make it easier for my code to work with PDFSharp/Migradoc to produce PDF forms, which are predominantly structured using tables. One such method adds text to a cell and has the follo... |
Recently I was reading the AMQP protocol specification from the official website, however, because this is my first protocol that I am trying to study in depth so couple of generic questions about protocols pop up in my head that I would like to find an answer.
How does a protocol contain type system, methods, constru... |
I have a class that does reboots a machine and then prompts it for readiness. The prompting is done via ssh and the standard output needs to be formatted to verify if the machine is in ready-state.
So should I write tests for the method that does the parsing? There's no actual logic in there, just cutting and joining o... |
Let's say my object needs to use an API to communicate with a device. The API call that I need is Api.do_something().
What would be the best way to solve this assuming that I need to call it only once? I'm inclined to use the third option but isn't dependency injection really too much of a hassle when I only need to ca... |
I have a specific use case, and have found 3 ways of doing it across the internet, which are defined for vague usage cases. I am staring at these three wondering which to apply.
I tend to sit there not knowing what to do - then doing nothing... Is there a good way of choosing? Should I try all of them?
To be more speci... |
I've inherited some awful code that I've included a short sample of below.
Is there a name for this particular anti-pattern?
What are some recommendations for refactoring this?
// 0=Need to log in / present username and password
// 2=Already logged in
// 3=Inactive User found
// 4=Valid User found-establish their sess... |
I have a class in python that is instantiated from the values of a (json) config file. I was wondering what is the best practise to do that (if there is a best practise and is not just a matter of personal preference).
I call a read_config function (which is defined outside the class) in my main, that parses my config... |
I created a wiki-like application. Currently, there is no security, so all the contents have "edit"-buttons where the user can edit everything. Now, I want my application to have a public read-only access and the read/write access to edit content.
First of all, I think it is useful to do that with two roles: viewer and... |
I have two cross cutting concerns in my design of my software. The memory allocator tracks memory usage in its struct(class) member variables. I also have a logger. Right now I am passing the logger and the allocator into the constructor of my objects. I can maintain a reference to them but then I would have to do ... |
My current task is to set up a system that pushes out notifications to specific users based on a set schedule. Having tackled the push notifications issue, I am now trying to put together a system that will actually send out those push notifications on a regular basis. Since our infrastructure is based on a Kubernetes ... |
Say I have a Calculator class similar to this:
using System;
public class CalCulator
{
public int Square(int num)
{
return num*num;
}
public int Add(int num1, int num2 )
{
return num1 + num2;
}
public double Add(double num1, double num2 )
{
return num1 + num2;
... |
Lets assume I have a string for a class name (or part of a class name), and I have implementation somewhere. All I want, is to be able to get an instance of a class with the name in the variable.
For example,
dynamic_class_name = "Circle" # not a constant, comes from somewhere
corresponding_class = some_magic(dynamic_... |
I have a function that I can implement in two different ways. Each way has its own advantages, and performance depends on the arguments it will be given. Since each implementation has several short circuits, performance can be dramatically different compared to the other one, so I thought to wrap the two implementation... |
I am using Command Pattern to execute actions and so I developed many command classes (CommandA, CommandB, etc.). Now I need a SuperCommand that receives a collection of data from legacy code, loops through it and calls one of previous defined commands depending on data type field.
The pseudo code of the SuperCommand s... |
I am building some middleware between our ERP and a cloud based online store.
We have multiple business divisions who will use this cloud based ERP, however each business stores their attributes (such as product related attributes) in different fields in the ERP. Because of this, I can't have a standard method of grabb... |
I am using a factory pattern to get objects that shouldn't be instantiated other than the factory class. These objects are of type ViolationType, which represent violations on a set of rule. Here is the summary of the factory and the available violation types:
class ViolationFactory:
def __init__(self):
rai... |
I am reading Martin Fowlers Refactoring book. On page 110 he talks about 'Replace Method with Method Object' where he turns a method with local variables into a class with instance variables.
The outcome is a class called: PriceCalculator with three instance variables i.e. primaryBasePrice, secondaryBasePrice and ter... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.