instruction stringlengths 34 36.1k |
|---|
I am writing a simple x86 disassembler in c++ and I would like to hear an input on class which will handle disassembly. I thought to make a class which would receive a pointer to the table which will contain instruction description. In that way I would have logic implemented in a class which could disassemble code for ... |
TL;DR. Writing procedural code within a DB transaction. How can I improve design of the code so it's better testable?
In my application I have a service object that perform multiple things within the same transaction. See code in Ruby below:
class CreateRefundService
def create(customer_id)
ActiveRecord::Base.tra... |
I know questions like this has been asked before. But none of them truly answered me.
How to keep a big and complex software product maintainable over the years?
How do you organize highly customized software?
...
We're working on a software that has a lot of rules and conditions. Also, those rules change frequently.
S... |
I was refactoring some java to use decorators. All of the decorators inherited from a class ThingDecorator, let's say. This consisted entirely of:
SomeType methodName(OtherType otherThing) {
return decoratedObject.methodName(otherThing);
}
For maybe 20 methods of that form. This is like writing "this thing is a... |
I use the repository pattern for data handling.
In my DAL folder i have IUserRepository, UserRepository and UserContext. Inside the models folder i have a class called User like id, username etc.
I read on the internet that I should do as less as possible in the controller. What do they mean?
I want to determine where... |
I'm trying to write a simple compiler for learning purposes. I've been reading the Dragon Book and Modern Compiler Design and one part I don't understand is how the Concrete Syntax Tree is actually created and stored.
I understand that by looping through the Tokens produced by the Lexer it's a simple matter to collect ... |
Template method pattern is commonly implemented with abstract classes.
interface Algorithm
{
void perform();
}
abstract class AlgorithmBase implements Algorithm
{
abstract void step1();
abstract void step2();
private void finalStep()
{
// common implementation
}
// Template metho... |
I am trying to understand static vs dynamic typing, but am really struggling to see how everything fits together.
It all starts with data types. As far as I understand, data types are quite abstract notions, which exist 'in' compilers in order to categorise data so that the operations on various types of data can be va... |
I'm currently setting up integration testing for my company. I haven't done it before. We are developing a Java web application which uses MySQL as datasource.
I know it is very common to use an in-memory database like H2 or HyperSQL for development.
My question is, is it best practice to use a separate in-memory DB or... |
I have a web application written in C# which uses external dll written in C++. Communication between clients (web browsers) and a web application is done using SignalR. For communication between web application and the dll I am using a class and I create an instance of this class for every connected client. Instance of... |
Background
I am writing a compiler for a custom language for a school project and it is going really well for me.
If I where to start all over from scratch I would have done many software architecture things different, but right now I do not have time or motivation for a complete rewrite so I will focus on just finishi... |
I came across and programming issue in my MVC app where I need to provide field-level security for some of my forms. So I need to display or hide fields on the form, based on the user's permissions. Additionally, I need to validate on post to see if the user can edit a field or add a new record.
The only solution I... |
We strictly adhere to inversion of control in our codebase, but that creates hellish constructors (yes, I know that means our classes aren't cohesive enough, this is a work in progress).
The thing is, that sometimes those dependencies are quite silly like a DateTime wrapper to enable date mocking, or the logger, or a T... |
Currently we are planning to switch from our software version 5.x.x to 6.x.x. Such major releases contains in our case a lot of refactoring work and changing the software architecture. Instead of creating a new branch for version 6 (git), I thought to create a custom repository for this. In general, developing the new ... |
Can somebody explain the difference between Bresenham and Midpoint Circle drawing algorithms? All I am able to understand is that in both algorithms we compute coordinates of an octant instead of whole Circle and in Midpoint algo we compute those coordinates by putting middle point of the 2 possible next coordinates in... |
A preface: it's well known that IEEE754 defines five rounding modes (in 2008 edition terms, with my abbreviations):
rounding to nearest, ties to even (RNE) - the default mode for binary arithmetic;
rounding to nearest, ties away (RNA) - required only for decimal arithmetic, rarely supported for binary one;
rounding to... |
I'm looking for a little bit of direction in writing a compiler. I've written in Common Intermediate Language, C#, and various other .NET languages; I've written my own Metadata Parser and now I'm trying to understand the various aspects of the Portable Executable (PE) layout. One thing that somewhat befuddles me is ... |
Suppose I have a REST API that is also used to set/reset passwords. Let's also suppose that this works over a HTTPS connections. Is there any good reason not to put that password in the call path, let's also say I will encode it in BASE64?
An example would be to reset a password like this:
http://www.example.com/user/j... |
I have a web project that requires I build a quiz and am having some difficulty working out how to efficiently code it. I'd like to create some sort of json template system so that the quizzes can be defined in a config file, my problem is that almost every question on the quiz is structured differently.
So some quest... |
I'm writing my first API, but I think I screwed it up from the design. It's a simple CRUD API which behave like this:
READ: /api/data gets redirected to api.php?data1=data. POST variables: user, HMAC, action (read).
CREATE: /api/newgets redirected to api.php. POST variables user, HMAC, action, data1, data2, data3.
DEL... |
I'm writing unit tests for a class that makes use of a general utilities module. In general I want to mock all the dependencies of the class, but mocking some of the utility functions feels weird. Some of them are simple functions for dealing with file paths, string manipulation, etc, and it seems like an implementatio... |
I've been working on a large Ruby on Rails application for several years. It was inherited in a poor state but most of the production bugs have been ironed out with time. There are some sections that have not been touched such as the payment processing code. The code works for the most part, except that whenever a char... |
public class MyButton{
public MyButton(){}
public MyButton setIcon(Icon icon){return this;}
public MyButton setText(String text){return this;}
}
And used like:
MyButton testButton = new MyButton()
.setIcon(MyIcon)
.setText("MyText");
I know its not a true implementation of the builder pattern, but... |
I apologize if I should be understanding this more readily but I'm a little new to this and dont understand the LGPL license. Here is the FAQ for it: http://www.qt.io/qt-licensing-terms/
I am making a website that scrapes data from other websites and organizes it in a nice manner. I plan to try and make money off thi... |
I have 2 domain objects: Project and Contract. A project can have many contracts so in the database it is modeled as a classic one-to-many relationship. Our question is this: How do you model the above in the context of microservices? Do you (a) have 2 microservices ProjectService and ContractService? or (b) Do you... |
A piece of code I'm trying to debug generated a sequence of 4 bytes from a known float number. I'm trying to verify the float number given the four bytes.
The (known) float 8.03 generated the bytes 56,46,48,51 (here, it is listed according to how it was received in a buffer i.e., 56 first, then 46, then 48, then 51). ... |
I have this easy DTO (Data Transfer Object):
public class SoonestOffersModel
{
public Offer Offer { get; set; }
public DateTime Date { get; set; }
}
Offer is entity.
Our architect is against these DTOs, as he is saying this is very old and it is in need only when people don't think about design to include all ... |
I have a dataset containing list of users (around 50M).
Each user has an email address, name, and some more data columns.
I want to send a weekly email to those users, and the content of the email will be based on the user's data.
Each user should get the mail on a specific day of the week, based on his registration da... |
It seems that the terms size and length are used interchangeably to describe how many bits, bytes or octets some data occupies, i.e. a length field in a data header is said to indicate the size of the data. Did I see this correctly? If not, how do the terms differ? Which term is most common for which usage?
|
During a recent phone screen I was asked to describe the "Factory Pattern". I asked if the screener meant "Factory Method" or "Abstract Factory". He said, "No, just the Factory Pattern".
I don't know what the Factory Pattern is except in the context of the aforementioned GoF patterns. I've been researching this since t... |
There are few GitHub repositories written in Swift that are presented to be "Linux Ready". The Zewo organization has several repositories identified as "Linux Ready". What, exactly, does this mean?
|
I'm looking at our current method of creating installation packages and quite frankly it's a bit of a mess with a large scope for human error.
We currently use InstallShield, but to get the files ready for the package, there is a lot of copy and pasting at release time and we're never quite confident that all files/dep... |
Recently for fun I have decided to build a toy programming, compiler and a low-level register based interpreted vm. While starting to implement the virtual machine I got stuck. The stack which holds the variables and structs I implemented as separate arrays for each type. The problem is when I have a reference to a st... |
I have a choice.
Option 1:
public class Sample
{
bool IsRelevant { get; set; }
}
Option 2:
public class Sample
{
}
public class RelevantSample : Sample
{
}
Is there a clear well-known rule how to make this decision?
My research: I have heard about "Replace Conditional with Polymorphism" refactoring before, but i... |
I have following questions about the super keyword in java:
I have a code below with classes:
A Extends no class contains integer variable i
B Extends class A contains integer variable i
C Extends class B contains integer variable i
class A {
int i = 20;
A() {
System.out.println("I am in constructor ... |
In my company there is implicit rule not to define multiple classes inside one .cpp file. The argumentation is that it looks like a mess and hard to read. But in my opinion it will make sense if the classes is related and not meant to be used outside compilation unit. Example:
example.h:
class ExampleState;
class Exam... |
I understand what they determine but is it really useful to assign those to issues found? I mean, it is either required to fixed quickly or not.
I know how to set them, categorize them etc. I know IEEE/ISO do require to do that. I just do not see why.
|
Let's say I have a Customer which contains an Address class like:
public class Customer
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public Address Address { get; set; }
// Constructor and other code
}
Should I now also have a property fo... |
I'm a web application developer for an internal system. A user reports that there's a bug.
The bug was that some words could not be displayed. The report contains a screen capture which clearly show the bug. But the report is almost a month old and the bug can no longer be reproduced in our production environment.
Ho... |
Given that the size of some sets (example, 52! (about 2226 or 8*1067), the number of ways to shuffle a regular deck of cards) exceeds the period of most Pseudorandom Number Generators (PRNG), is it true that some combinations may be unable to be generated by the PRNG?
Does it matter if tries to permutate the array, vs.... |
I've been taught that exceptions should be have concise meanings and should contain a message that explains to the client what the exceptional situation is. I am wondering, since I found a piece of code that contains a couple of lines into a try catch block and in the end catches a generic exception with the message: A... |
Why would I ever throw exceptions in code? (except for one specific scenario where I am developing a class library which the consumers of it, will not want / be able to change).
To be more specific, is there any reason to do this:
class EmailSender
{
public void SendEmail(string recipient, string subject, string con... |
This is supposed to return an infinite list of x's. However a list is created using an element, then the operator ':' and then a list.
The recursive definition of repeat' x = x:repeat' x seems to never get to the point where an actual list is created as it seams to continuously add singular elements (where?), doing som... |
I have a basic gap in my knowledge when it comes to open source licensing.
I realize that the answers to this question aren't legally binding :).
With that being said, let's say I am writing a custom application for a client. It will run on their infrastructure.
Assume that:
I add a library to the project via NuGet... |
In our software we have a client/server architecture where the server is actually running on an embedded system with various hardware components (sensors, etc.). The different sensors as well as other features of the system itself can be configured by the client. The client does not know in advance which features and c... |
At my company, we've standardized on Bamboo for continuous integration. One of our products is a Server + a set of clients, and we want to test many different combinations. The way we do it is to have plans with two stages, the first starting the servers, and the second starting the clients and running tests. This is d... |
I'm working on an ASP.NET MVC project. I have a form that is strongly typed. Is it considered good practice to add serialisation attributes to the same view model to control how the data is serialized once it is posted to the server. For example, I have many properties that are strictly used to show/hide UI components.... |
I have already built a nodejs webapp that I want to make available as a service, but I don't know the next steps to automate the whole thing given the following steps :
people come to my website and create an account for a free trial by providing what could possibly be the domain name for their version of my app (... |
Usually when I program, I have a clear task ahead of me, but find annoying things I'd like to clean up as I go on.
Here I see three options:
Do it later (may forgot/have to spend time adding a ticket)
Do it now and commit it together with my current work (unclear)
Do it now and the commit it separately (have to find i... |
First, I am well aware of Why is there no 'finally' construct in C++? but a lengthy-growing comment discussion on another question seems to warrant a separate question.
Apart from the issue that finally in C# and Java can basically exist only once (== 1) per scope and a single scope can have multiple (== n) C++ destruc... |
So me and my team have been doing estimates for a new project but we have been getting the feeling lately that the customer has trouble understanding not the estimates in itself but what the stories described actually contain.
We have been thinking of going through their RFP documentation and in this document make a co... |
We work on an Application which displays a duty roster and also some other DateTime related things.
So my Database is full of Relations like in this small Example:
This results in big StoredProcedure to get all Employee Data and it's Date related Data for a given Employee and Day, Month ,Year combination
which looks ... |
I have a contact table which stores all the contact information of a person such as name, address, phone number.
The system would be more user friendly if it can prevent users from accidentally entering duplicate records.
If it is unique it will be more user friendly, but it costs performance to check, plus the added c... |
Say I have have a class Event as follows:
class Event {
private var attendees: [Person] = []
// Case 1
//*******
// Should I use a func…
func countOfAttendees() -> Int {
return attendees.count
}
// …or a var
var countOfAttendees: Int {
return attendees.count
}
... |
I am working on this web application that already has a mechanism that allows a developer to define server side JavaScript functions that can then be called by other server side JS code.
There are two ways to define these functions.
This way...
function iAmFunctionA(arg) {
...some code...
}
function iAmFunctionB(ar... |
I'm familiar with C, but haven't written any medium or large application in it. I have a requirement to built an application that can be run as a standalone console application as well as Fast-CGI and Apache module.
I'm thinking of implementing the core functionality as a Static Library and then write a wrapper for con... |
In a SaaS solution, that allows users to maintain their data on the server, if I have to implement various pricing schemes, where each scheme offers different storage quota, say, Basic subscription gets you 2GB storage, whereas Premium gets you 10GB storage - what kind of architecture one has to use?
Do I need to main... |
I'm learning to program microcontrollers and am trying to develop good habits:
Suppose I have a set of values which can be calculated based on what is already in memory. As a general rule, is it always better to calculate the data once, and save it in memory, or is it always better to calculate it each time it's neede... |
I've a helper class in Laravel 5.1 with static methods for calculating week numbers, dates in weeks, etc. (Why static? I need max. 1 instance of this helper class)
I need this logic in my views. I'm using MVC pattern. My question is quite simple:
May my view call the helper methods directly?
Or: is my controller respo... |
I have a bash script that should be extensible with additional functions with as little change to the script as possible.
The basic function is as follows. It loops through a list of files to check. The idea is that each check should be independent. A new check should be possible to add with the least possible change ... |
This isn't an actual code related question but it relates to C. We are given:
Amy's club has grown and now includes the following members: Abel, Abigail, Abraham, Ada, Adam, Adrian, Adrienne, Agnes, Albert, Alex, Alfred, Alice
Find what value would be computed by Amy's hash function for each member of the group, befor... |
Providers of new computer architectures regularly try
to introduce new programming models, e.g. recently
CUDA/OpenCL for GPGPUs, and displace C/POSIX as the
control interface to platform parallelism. (Poss & Koening, AM3: Towards a hardware Unix accelerator for many-cores, 2015)
Why do architecture designe... |
I'm working on a software to integrate an e-commerce store and the company ERP. All the integration steps are run as a unique batch job, every 5 minutes. Things are working under production, but I'm struggling with how to better design the subsystem that alert us (developers and IT folks) that an integration error is o... |
A example of what I want to do:
User puts numbers into a list on a GUI that looks like this
| L1 | L2 | l3 |
----------------
| 3 | 6 | |
| 5 | 3 | |
...
He writes in a text area an equation like this; L1+L2[STO>]L3 and hits calculate and it updates the list to this
| L1 | L2 | L3 |
----------------
... |
I'm trying to learn about event sourcing for potential application to a booking system I am building - I think I understand the core concepts, but I'm having trouble understanding how to handle cases where updates to multiple aggregates / streams are required.
In my case I have modeled two aggregates - Events, which tr... |
My R&D team has been working on a major product for over a year and we're using JIRA for issue management.
Now got more minor, distinct products (not related to the previous one), and would like to separate the issues, versions, etc.. related to these products.
We thought of the following options:
Different JIRA Proje... |
I encounter this issue multiple times, but I'm never sure how best to deal with it.
Basically, some methods I write require the implementing object to support multiple interfaces. The example I have in mind is that a table structure needs to be able to IIterate over its records and IStreamable its content, where
IItera... |
I need to develop a batch processing that will be executed every day. These are the steps:
Read each line of a database table that contains a URL (SQLite)
Extract some data, say Users, from that website by scraping it. Each website may contain 1..n users.
Persist each User in a local NoSQL database.
Send each User(one... |
I'm currently working on a project which only uses its database for data storage. This means there are no triggers or stored procedure in it, just tables and data to put into it. In this scenario I'm building the application using Spring 4. The Spring container allows you to have profiles, which basically decide which ... |
I guess this is another question about hard coding and best practices. Say I have a list of values, lets say fruit, stored in the database (it needs to be in the database as the table is used for other purposes such as SSRS reports), with an ID:
1 Apple
2 Banana
3 Grapes
I may present them to the user, he selects o... |
When using reactive frameworks I have seen both solutions below to make a mutually exclusive selection of which stream will be forwarded (rxjava in this case)
Observable.merge(
Observable.just(aBoolStatement).filter(aBoolean -> aBoolean).flatMap(aBoolean -> signal1),
Observable.just(aBoolStatement).filter(aBoolean ... |
Given a list of integers whose length is unknown, and each of its elements lies between 1 to 1000, how does one sort this list in linear time?
|
I need to know if I can get acceleration data from an IMU at 500Hz via USB.
I've been going through the code that the manufacturer provides and trying to improve it. Right now I cannot go faster than 166Hz. Things I've tried:
Switched from streaming mode to polling. The reason is that in streaming mode the SDK of the... |
I'm making a Book Manager App using Java Swing that allows me to do a variety of things such as opening a txt list of books, searching for books, adding/removing books.
There are different classes for the different types of books e.g. Fictional Books have their own genre field and history books have their own period f... |
I'm working on refactoring a synchronization web app that our company uses. Currently it's merely a set of controllers that fire up a set of helpers that go through a long chain of if-else type statements.
I'm attempting to build a wrapper around the SalesForce Soap web reference, but I'm having some trouble coming up... |
I had this discussion with co-workers before. We had to store users by id and we'd do mostly Add/Get operations on it. I proposed to use a Dictionary which seems like the logical choice. My co-worker argued that the Dictionary was pointless in that case because we didn't have many users (Maybe 150).
I proposed the dict... |
I have a couple wrappers around third party APIs that allow me to retrieve information from certain web services. Querying these services can be rather time intensive, so in my older version of my application, I created globally static objects that maintained a cached list of data for later querying.
How can I still ma... |
I think I'm in the minority on this but would be curious to see other perspectives.
A lot of times I see people talk about the Data Layer like having functions like UpdateCustomer() or Summarize(). I really feel like the Data Layer should be more abstract than that. I currently use a generic Repository pattern on top o... |
The premise is that you have a Stream - a source of events spread over time.
You can connect to Stream and create a logical chain that will fire when a new event is emitted:
var button = document.querySelector('#button');
var clickStream = Rx.Observable.fromEvent(button, 'click');
clickStream
.map(...)
.subscr... |
I am the sole maintainer of a code base of about 2000 lines of code. It's not big, but over time the code became so unmaintainable my boss agreed to give me time to rewrite it from scratch.
Since the code became such a nightmare to maintain and extend, I wanted to do things right this time and thought about writing uni... |
I am using this go library(https://github.com/abourget/goproxy) to create a custom proxy server app. The app is utilizing several middleware of the following form:
MyMiddlewarFunc(ctx *goproxy.ProxyCtx) goproxy.Next {
if ctx.Req.Header.Get("If-None-Match") == "test"{
//do something
}
}
Now, I am trying ... |
A lot of projects have a to be determined database model during early development. This could mean that a lot of SQL will have to be rewritten frequently. What is the recommended strategy to deal with this? Especially when you want to develop your application RAD-like and with the ultimate requirements not being set in... |
The stack pointer points to the top of the stack, which stores data on what we call a "LIFO" basis. To steal someone else's analogy, it's like a stack of dishes in which you put and take dishes at the top. The stack pointer, OTOH, points to the top "dish" of the stack. At least, that's true for x86.
But why does the co... |
If I found a post that properly quotes code (gives attribution) from an original source, is it ok if I attribute to that post only, or do I need to give attribution to the original source?
For instance: I found this StackExchange answer: https://unix.stackexchange.com/a/4533/92787 :
Remove color codes (special charac... |
We are currently developing an image processing restful api. Server performs some CPU-heavy computations image processing upon request and return the image to the client.
We want to make this a single http request (all computation should be done).
My questions.
What is the best workflow for this. With speed has an hig... |
From : http://www.artima.com/lejava/articles/designprinciples4.html
Erich Gamma: I still think it's true even after ten years. Inheritance is a cool way to change behavior. But we know that it's brittle, because the subclass can easily make assumptions about the context in which a method it overrides is getting called... |
We have some data that is strongly bound to each other and we are using it for calculations. Its a value with a unit type and an optional relation.
E.g. 1500 meter above sea level.
The unit type should be replaceable (meter to foot). But the value should be converted accordingly.
I am currently thinking of two approach... |
I was looking over some of the general Big-O Algorithm Complexities for different data structures, and wondered what Java's ArrayList would be considered.
Since I tend to default to an ArrayList in my Java code when I need a List (unless I know I need some additional functionality), I was wondering what advantages ther... |
There are two arrays of maps. The first array contains maps of ID values in a specific order (but not necessarily either pure ASC or DESC ordering):
// pseudo code
first := [
{"id": 1},
{"id": 2},
{"id": 3}
]
...and an unsorted array of data with corresponding ID values, but not in the same ordering:
se... |
In our org , we have soap & rest based services that have focused set of responsibilities. For instance , there is customer service for managing customer info , account service for managing account info etc. Is there any advantage of making them microservices? If it has to be converted to a microservice , what typicall... |
Suppose I have a very simple C program that just does this:
int i = 6;
int j = 4;
int k = 5;
int a = i + j + k;
Since i, j, and k are on the stack, they will be located relative to the stack pointer. I am told the compiler determines these relative locations; my guess is the compiler translates int a = i + j + k into ... |
I'm creating images with centered text. I use Python but I'm faced with many question regarding how to write my class.
I know that
A class must aim to do one thing and do it well.
Well, the one thing I want to do with this class is print centered text on a background image but I think I need help to really understa... |
Premise
I have a number of database servers (different DBMS instances, installations in different physical locations), each of them contains data and uses the same schema. Most of the data is completely the same across all databases, but unfortunately not in every case.
I need to write an application that will issue qu... |
I'm asking this question because there doesn't seem to be a "recommended" approach for this.
If a page had a directive with isolated scope, and if the directive needs to update itself after an event triggered in the parent controller, there seem to be 3 ways to do this:
$watch an integer scope property in the directi... |
Liskov's work in this area focused on behavioral subtyping, which besides the type system safety discussed in this article also requires that subtypes preserve all invariants guaranteed by the supertypes in some contract.[3] This definition of subtyping is generally undecidable, so it cannot be verified by a type chec... |
For a school assignment, I wrote up a web-page in HTML5.
After looking over the assignment's requirements again though, I found the line:
• a minimum of three HTML pages complying with at least XHTML 1.0 standards or (better).
I'd really rather not need to add all the ugly tags to the top of the page, and change all ... |
Based on your experience, when do you need to perform a performance and memory profiler for a web development project in C#?
Today, Im newbie in performance and memory profiling.
|
I heard that some sort of class system will be added to JavaScript with ECMAScript and I find that a little confusing, because I've just finished reading a JS book, JavaScript, The Good Parts by Douglas Crockford, where he explained that the lack of classes wasn't a bad thing at all, it was just different. I believe I'... |
I am given N lines, i.e, I am given a,b,c for N lines. And each line is of the form ax + by + c = 0. I need to find out the maximum number of lines that are parallel to each other.
For this, first I create a 2 dimensional array of the ratio A/B (-slope) and C/B (-intercept), except for b == 0 (for which I take slope a... |
I'm planning to open source an Android app that I developed against the API of a (small regional) social network.
This app is the 'official' version for the website and thus allowed to use the logo and name of the website.
I plan to open source it under the GPL, but:
I cannot put the logo or name under the GPL (I don'... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.