instruction
stringlengths
71
71.9k
I've written a program to compare different sorting algorithms with the array size being 10, 1,000, 100,000, 1,000,000 and 10,000,000. I, of course, expect Insertion to win out on 10 and merge heap and quick to really perform at the upper levels. However, below are the times I'm getting. (Note that quick sort is growin...
I am learning C and wrote a function to concatenate two strings in C. Please let help me improve it. #include <stdio.h> #include <string.h> void concat (char result[], const char str1[], int n1, const char str2[], int n2) { int i, j; // copy str1 to result for ( i = 0; i < n1; ++i ) result[i] = str...
I am following the Wikipedia definition of the Bloom filter. My implementation uses the BitArray I created here. Here is an alternative implementation by Ilya Grigorik. # n = Number of items in the filter # p = Probability of false positives, float between 0 and 1 or a number indicating 1-in-p # m = Number of bits in t...
From the back-end, I am receiving 8 data. The client requires showing that the row per data is 7, so I have 1 data in balance. I have created empty data and made the empty cells, which works fine. But is it a correct approach to using Underscore templates? Here is the live demo Template: <script type="text/template" id...
Binary Search Tree, with preorder traverse. What other methods should I add? How can I improve it? class Bst attr_accessor :data, :left, :right def initialize(data) self.data = data end def insert(data) if self.data < data if (self.right ) self.right.insert(data) else ...
Description Print all student names from a CSV file. CSV Format: CSV file does not contain string delimited by double quotes. None of the cells has "," character or "\"" character. There are exactly two columns. No empty cells. Code csvread.pl #!/usr/bin/perl use strict; use warnings; my $filename = "students.csv"...
using Excel = Microsoft.Office.Interop.Excel ... Excel.Application app = null; Excel.Workbooks books = null; Excel.Workbook book = null; object[,] data; try { app = new Excel.Application(); books = app.Workbooks; book = books.Open("C:\..."); Excel.Worksheet sheet = book.Worksheets[1]; Excel.Ran...
I wrote the following atexit implementation for Bash #! /bin/bash set -e ATEXIT=() function atexit_handler { local EXPR for EXPR in "${ATEXIT[@]}"; do echo "evaluating $EXPR" eval "$EXPR" || true done } trap atexit_handler EXIT function atexit () { local EXPR for EXPR in "$@"; do ATEXIT+=("$E...
I've written a function which can get the environment variable's value. The input parameter would one of the following: ${machine}/bin ${machine/bin} ${machine}/bin${path${OS}}/path I would need to check the values which start with ${} I've written a function which is recursive in nature, and I would appreciate it i...
Can the following condition be optimized/simplified ? if (!this.properties.width || this.properties.width <= 0 || !this.properties.height || this.properties.height <= 0) return; So basically if properties does not have a width or height property or the width or height property is less than or equal to...
I have the method below but I am going to have more methods similar to this one. They differ in is the last parameters being passed to the method. The first three parameters will always be there and then in the while loop with && conditions, I am going to use the same params that I am passing in. I am going to need fiv...
I want to generate a 'dictionary' containing all 8 character permutations of upper-case letters such that the output file looks like: AAAAAAAA AAAAAAAB AAAAAAAC ... ZZZZZZZZ I came up with this solution that uses the product method of itertools: from itertools import product per = product('ABCDEFGHIJKLMNOPQRSTUVWXYZ'...
I have a LINQ query which works fine. I am however very interested to understand if this can be written in a more optimum way... var query = (from r in Results.All.AsEnumerable() where r.RequestType.Id == Id && r.DateFrom >= sDate && r.Dat...
In one of my recent projects I faced the problem of transforming an abstract class into another abstract class. The classes were structured like this and are part of an api for questionnaires: abstract class AnswerConstraint { /* shared implementation for all entities */ } class LengthConstraint extends AnswerConstrai...
The following code is developed around a mysql database where the posts table has 3 columns: post_ID, date and title. config.php holds the values for $dsn, $username, $password, $options. The content for each post is held in a directory format: year/month/day/(database column)title/content.txt By querying the database...
It return an object with WebAPI by proving some data. Is this a good approach? using MWM.Database.Model; using MWM.Entity.API; using MWM.Repository; using MWM.Services; using System.Net; using System.Net.Http; using System.Web.Http; namespace MWM.Web.Controllers { public class JobController : ApiController { ...
This converts a "numerical number" to a text representation, for example: convert 1234 --> "One Thousand, Two Hundred Thirty Four" I'd like general feedback on how it could be make more readable or idiomatic. There are a few specific points I'd like improved as well. The word lookup functions are a little messy. Each...
I am in the process of diving a bit deeper into JavaScript development and am looking at some common language patterns (module, and factory in particular). In this code, my aim is to create a re-usable framework for creating custom field validators in JS that can be easily extended. In addition, I want the code that ...
I have two matrices, the first one is mat 2000*500, the second one is 6000*500 tep I did this code for some analysis to get another matrix that has a specific elements. Problem is : This code is very very slow, I need to make faster.Any suggestion to do so is welcome mat=matrix(sample(c(0,1,2),200,replace =T),nrow=500,...
I wrote some code for an application that uses the following pattern: function _getData() { return new Promise(function(resolve, reject) { if(_hasDataTypeA()) { SomeBackendAccessObject.getTypeAData().then(resolve, reject); } else { SomeBackendAccessObject.getTypeBData().then(...
I am making a game that uses a text map to draw obstacles and courses for the player to navigate. However, I am concerned that my method of looping through the text map to draw objects on the screen isn't as efficient as it could be. View the playable project on Khan Academy. Here is my code dealing with the text map: ...
Several hours ago I posted this question about Generating character permutations in Python. User rolfl said that my main problem was not using the right tool for the job, as Python is interpreted it will be much slower than a compiled solution. So I tried to write this in C. Objective Generate a file containing all f...
I have seen the Writings on the wall... Retro Rocket ASCII Art Nested for-loop art Print the Retro Rocket Maybe a golfed C# answer from me But I took this relatively serious and created a VerticalRocket class that I would like reviewed, kind of like a little "am I getting better at writing code" project/review exper...
Description Very small subset of Forth This is a proof of concept level compiler, no optimizations or over/underflow checking See the embedded POD for more information NASM is used as assembler gcc is used to link with glibc 32bit ELF Binary is generated bhathiforth.pl #!/usr/bin/perl use strict; use warnings; use f...
Here is my objective: Ask how many categories there are for the class (ex: Labs, Tests, Homework, Quizzes), and then ask what total percentage each make up for the class (ex: Lab are 15%, tests are 60%, so on), and then ask how many items there are under each category (ex: 7 labs, 3 tests, so on), and then ask for the ...
For an HTML calendar with jQuery, I put in event listeners to enable jQuery drag-and-drop that reads and writes to persistence using HTTP get and post with JSON structures. Now I'd like to make the code more readable and easier to follow and understand. Can you let me know suggestions on how to improve? My plan is to m...
I'm trying to learn the process of defining/calling a (somewhat) complex function. I understand the main idea, and can do it on a small (simple) scale. A simple example: def multiply(x, y): return x*y numb1 = 2 numb2 = 3 print(multiply(numb1, numb2)) Now what I'm trying to do is clean up my Vigenere cipher by d...
I am learning design patterns from Design pattern for dummies. From that book I have written a chain of responsibility pattern with two programs. Can someone review and let me know which one is proper chain of responsibility design pattern? A) #include<iostream> using std::cout; using std::endl; const int FRONT_END_H...
I am developing a set of simple JS functions which can be used for most commonly required JS functionalities. I want the functions to be very easy to use for new JS developers. Is the code structured well? How can it be improved? "use strict"; /* getElement, elementBase must be included */ var littleJS = function() { ...
I have created this MySQLI Class. I wanted to know if this class is secure enough to be used on the production websites or more improvements can be done to this class. <?php // Make local variables of the mySQL variables from the Configuration file $db_host = DB_HOST; $db_user = DB_USER; $db_pas...
I have an Entity class that can be either dead or alive. I store entities contiguously in a resizable array. During an update(), some alive entities can become dead, and some new entities can be added at the end of the array. The range [0 .. size) contains all non-newly-created entities. The range [size .. sizeNext) c...
Wrote this function for a Stack Overflow answer. It started off pretty bad but in the end I polished it a bit and now I have something I think to be pretty clean. Actually, when I look at the code, this is what I usually write when I'm programming AS3 (minus the documentation, I'm a lazy bastard, although that's slowly...
I've a code which applies marquee to certain elements by using the requestAnimFrame method. However, when I test my application on a lower spec PC (Intel Celeron 2.13GHz dou core) the CPU usage is skyrocketing and gets to a minimum of around 80%! (I have to mentioned that I have 2 elements that the custom maruqee is ap...
I wrote this generic task scheduler for executing tasks in fixed-delay intervals. Can you find anything wrong with it, or issues that may arise from using it for sending something like queued mails in a database? package system; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.S...
I've written a implementation of a merge sort in Python. It seems correct and I have tested it with this: l = list(range(1000)) random.shuffle(l) # random.shuffle is in-place mergesort(l) == list(range(1000)) # returns True # Stable sort cards = list(itertools.product(range(4), range(13))) random.shuffle(cards) cards ...
Recently I sent this code snippet as CV attachment and I got simple answer - this code smells and we employ another developer. I'm new to RoR, so guys can you give me directions to refactor this code and make it amazing? This code is for parsing uploaded file with GPS data in 3 supported formats CSV, xml, tes (binary)....
I have written a program to split a Multi-FASTA file into individual fasta files. use strict; use autodie; open( my $IN, '<', $ARGV[0] ); my ( $id, $seq_obj ); sub dump_seq { my $sid = shift; my $seq = shift; my @parts = split( /\h+/, $sid ); my $f_name = $parts[0]; $f_name =~ s/\|/_/g; $...
I've created a simple picker which is going to be used to select the number of rows and columns when constructing a table. Here's the example: http://jsfiddle.net/tnn3qgvj/8/ HTML <input type="text" value="1 x 1" class="grid-chooser"/> <div class="grid"></div> JavaScript $(function () { var rows = 5; var cols ...
My current code for scrolling an image contained within a div is: <html> <head> <style type="text/css"> #scroll { position: absolute; white-space: nowrap; top: 0px; left: 200px; } #oScroll { margin: 0px; padding: 0px; position: relative; width: 200px; ...
I have a form that displays a list of days in a given month that looks like so: All the text boxes are set as readonly, which is the desired functionality. While setting enabled to false works, it gives the control a blurred out look, which is difficult to override. In order to complete them, I want to keep the user f...
Here's some part of my code is use to draw objects on the screen : Class members: private double cursorX = 0; private double cursorY = 0; private LineObj cursorOldY = new LineObj(); private LineObj cursorOldX = new LineObj(); private int index1 = 0; private double cursor2X = 0; private double cursor2Y = 0; private Lin...
In the Excel vba sub below, I need to insert the number of rows equal to variable j after row k. So if j=17 and k=2 then I want 17 empty rows after row 2. How can I improve this code? sub stuck() Dim ws1 As Worksheet Dim ws2 As Worksheet Dim LastRow As Long Dim i As Long, z As Long Dim j As Long, k...
Could you please review my code and let me know if there is something wrong? I'm getting the expected results. I'm trying to do change data capture using hive. We already have an existing CDC in DataStage, but we are trying to implement in HIVE now. Here is what I have done, please correct me if I'm doing something wro...
Original question: Basic C# calculator (+,-,*,/) My 'teacher' requested this problem be solved by parsing the input into a tree based on the order of operations. The class Calc variables are specific to his instruction (except precedence) as well as the getValue() method. Everything else is subject to review. I'm hopin...
I have implemented for learning purposes a simple K-Means clustering algorithm in Rust. For those who are not familiar: you are given N points, say in the plane, and you want to group them in n clusters of nearby points. To do so, you start with n random points, for instance the first n of the given ones. Call these ce...
I have implemented Prim's Algorithm in Java. I am wondering how it can be made more efficient. Below is the class Node for vertices. public class Node { private final char label; private final Map<Node, Integer> neighbourList; public Node(char label) { this.label = label; this.neighbourList = new Li...
Background I'm writing user input validation for a client-side JavaScript web application. Users enter numerals representing an integer into an <input>. As part of validation, the application must check that parseInt(input.value, 10) will result in the integer represented by the user's input. In JavaScript, all numbers...
The following program is a solution to Project Euler Problem 23. That problem defines an abundant number to be one whose sum of proper divisors is greater than it, tells us that all integers at least 28124 can be written as a sum of two abundant numbers and asks for the sum of all numbers that cannot be written as a su...
I have a service class called ClientService, the service class is called using an interface IClientService. The service class simply does CRUD methods for the DbSet<Client> in my context class. In my service class constructor I have: private MyContext context; public ClientService() { context = new MyContext(); } ...
I recently posted about a basic XML writer in C++ and got a lot of great feedback. Well, I'm back with an updated version of the XML writer that is a bit less basic, but hope it's better than the previous. I've implemented a stack, better handling of the string writing and attributes, and default and custom constructor...
In the process of trying to build a serializable data structure, I found myself building large strings, which gets very slow because VBA copies a string every time concatenation is performed. To alleviate this, referring to Dynamic Array and Java's StringBuilder interface, I cobbled together a unicode clsStringBuilder ...
I have a couple of calls that I need to cancel a subscription based on a CancellationToken. I saw How to cancel an observable sequence but I needed a more generic way. I created an extension method that seems to work. public static IObservable<TSource> TakeUntil<TSource>(this IObservable<TSource> source, Cancellation...
I'm doing some Python practice for fun and I wrote some code that converts between two bases. I'm thinking about expanding on this later, so the docstrings are pretty redundant from function to function. Is this too much? Is there a way to make the documentation more clear or are there parts that I could just the let c...
I was given an assignment to check for balanced parentheses from an arbitrary string where parentheses are defined as (, [ or { and their respective "closing" parentheses. The other requirement for the assignment was that I had to use either Stack<T> , Queue<T> or List<T>. Here is my implementation: private static voi...
I want to add a class to only those <p> elements that have an <img>. So far this is what I have, it works, but I don't think I'm doing it right. $(".entry-content p img").addClass(function(){ $(this).parent("p").addClass("no-orphans-ctnr"); }); Here's a Demo/fiddle. As you can see, I used the .addClass() method tw...
I am working on a basic linked list implementation of a stack of ItemType (currently set to double but can be changed) values. The stack code will then be used in a function that reverses a sound data file by reading in all the data samples, pushing them onto a stack, and then creating a new sound data file while poppi...
I've come up with a very efficient way of finding if a number is prime, using TI-BASIC for use with TI-83/84/+/SE calculators. I am trying to optimize it however possible. :Input "NUMBER: ",A :If A<2 or fPart(A :Then :Disp "INVALID INPUT" :Stop :End :0→B :2→I :While I<A and not(B :If 0=fPart(A/I :1→B :I+2→I :If I=4 :3→...
After a successful fgets(buffer, ...), it is often desirable to trim a potential End-of-Line '\n'. Of the following 2 methods, are there any shortcomings? #include <stdio.h> char buffer[100]; // Method 1 while (fgets(buffer, sizeof buffer, stdin) != NULL) { size_t len = strlen(buffer); if (len > 0 && buffer[len -...
This reverses the case of a character in a string (a string being an array of characters). How does it look? Anything I can improve on? Besides documentation, in particular, any thoughts on the type casting found in str_case_rev? #include <stdio.h> // fprintf #include <stdlib.h> // malloc #include <string.h> // strlen...
I'm given a hexadecimal number in string form with a leading "0x" that may contain 1-8 digits, but I need to pad the number with zeros so that it always has 8 digits (10 characters including the "0x"). For example: "0x123" should become "0x00000123". "0xABCD12" should become "0x00ABCD12". "0x12345678" should be unchan...
I'm preparing for an interview soon, and I've written the following linked list implementation from scratch. This is all self-taught, and I'm still working on my C. I feel that the implementation is correct (if someone catches a corner case though, that would be great!), and I'm looking for feedback on best C practice...
I'm trying to brush up on my algorithms and data structures and wrote a fixed sized hash map assuming both key and value will be only integers. This is a significant simplification of the real case and is supposed to be so. Any comments regarding bugs, best practices, style is gladly appreciated. #include <vector> #inc...
Any thoughts on my actor model here? Obviously it doesn't have implementation for concurrency as it stands- being completely synchronous, but it should be easy to make the send/become/create be sent to a thread pool without effecting the overall API, no? All state for each actor is local and immutable only through beco...
GetBootstrap v1.0.0.2 a console customizer update from this Please give me tips, request and suggestion for my future updates. (I update every 2 weeks) Sample Preview The following code contains the Write(), WriteLine() and Typewriter effect of the console. using System; using System.Linq; using System.Threading.Tas...
This is the first program that I have written in my C++ saga that I actually think is useful. The description for this assignment is kinda long and mundane though: Write a program that inputs a date (for example: July 4, 2008) and outputs the day of the week that corresponds to that date. The following algorithm...
This reverses the case of a character in a string (a string being an array of characters). How does it look? Anything I can improve on? Let's get critical here. #include <iostream> #include <string> // // return a new string // std::string camel_case_rev(const std::string &word) { std::string ret = ""; ...
I am repeating this code at lot of places: public class ProductTypeService : IProductTypeService { public async Task<IList<ProductType>> GetAllAsync(int sectionId = -1) { string key = "ProductTypeService_" + "GetAllAsync" + sectionId; var list = _memoryCacheService.Get<IList<ProductType>>(key); ...
Is ProtectedObject really secure? Otherwise, do you have any advice? public class ProtectedBinary : IDisposable { private byte[] pBArray; private int originPBArraySize; public ProtectedBinary(byte[] data) { originPBArraySize = data.Length; Pad(ref data); ProtectedMemory.Protect(...
I am familiar with using storyboards to construct UI elements in Xcode, but I am only beginning to learn how to make UI programmatically (without a storyboard). I wanted to know if this is the correct way to implement a UIView into an existing ViewController class. DetailView (Custom UIView class): .h file (header) @in...
I have an MVVM WPF application that will make use of a repository and unit-of-work. This is my Entity Framework database-first model: public partial class tUser { public string ID { get; set; } public string Name { get; set; } public string Surname { get; set; } public string Password { get; set; ...
Below are a few of my handlers and helper methods. This works perfectly fine, but I'm pretty sure I'm breaking about 1001 modern conventions and possibly even optimizations. Could you provide some insights as to how I can improve the structure and design of this code? function getSelectedId() { var grid = $("MainGr...
I'm currently learning about PDO, and trying to connect to the database and CRUD in OOP way, this is a simple code that I use. index.php include_once("connection.php"); include_once("model.php"); $con = new Connection(); $model = new Model(); $model->insert(); $con->closeConnection(); connection.php class Connec...
Here's a function doing some trajectory optimization in the following manner: for position in sref_ ... // get position data // start parallel region for time in vtwin->trefloc_ // time will be offsetted for start_velocity in vtwin->vrefloc_ // start_velocity will be offsette...
I write my log messages in JTextArea. Each message should have a time added. I created a following method: public void log(String message) { logTextArea.append(String.format("%s : %s%n",DateFormatUtils.ISO_TIME_NO_T_FORMAT.format(new Date()), message)); } It uses DateFormatUtils from Apache Commons Lang. Each tim...
I'm currently working on an in-house project and a part of that project is this pretty standard plugin loader below. There must be a way to avoid so many ugly looking else statements. I'm kinda hitting a brick wall with getting better at "writing less to achieve the same thing". How I can improve the code as I do think...
I'm pretty very new to python, so I thought that I'd write a game to teach me python and better teach me how to think in hexadecimal and binary. I'm starting off by writing a few functions to convert between the different bases. I'm looking for feedback on any better ways to implement these functions. There might be p...
I am trying to make my script maintenance-free by replacing some "static" variables and labels with dynamic ones. The main function of my code is to extract data from a SharePoint-list which contains a number of list items with several columns (including a column for school), then count the number of items based on a s...
This represents a UI-slider widget - there are a number of different widgets on the page. This function is repeated per widget - 90% of the code is the same - the only difference being that each has a unique getDesc() function which is called by the slider events. My gut feeling is that these widgets can be refactored ...
Description Calculate how many mugs StackExchange should give away(for graduation) to top reputed users on codereview.stackexchange.com so I'll also receive one. (output is divisible by 50). Code DECLARE @mugs INT,@rounded_mugs INT,@inc INT,@remainder INT; SELECT @mugs = COUNT(1) FROM Users WHERE Reputation >= (SEL...
I am trying to make Dijkstra implementation more efficient. Below is the code for class Node which implements Comparable so it can be used in PriorityQueue. public class Node implements Comparable<Node> { private final char label; private int distanceFromSource; private final Map<Node, Integer> neighbourList; public ...
I am trying to build a very basic JS framework for my own uses, ultimately collating a lot of pieces of JavaScript I have created over the years. But I would not call myself a JavaScript expert. What I have written below works well enough but I really would like to know if I am making any fundamental errors in the way ...
The standard C library function bsearch wasn't giving me correct results, apparently. So I decided to implement a binary searching function in place of it. It functions correctly up till now, though I haven't tested it thoroughly. void * bsearch2(const void * base, const void * elem, const size_t nmemb, const size_t si...
What i have so far is a nice and rapid algorithm for finding the pixel dominant from bmp image. I am not sure how to make it to work.. i though it works, but the program freezes. RGB bitfox_get_primecolor_direct (char *FILE_NAME) { RGB primecolor; BYTE rgb[3]; dword *counts = calloc(pow(256, 3), sizeof(*co...
I have a method which should accept a Function/Action and do something with that method (in my case I've added retry logic). I'm wondering how I can remove the duplicated code (for loop, etc) from the last 2 methods. Is there any clever way to do this in C#? public static class Retry { public static void Do( T...
A couple of date-related questions have come up recently, and on both occasions I have been taken back to my 'early' days where one of my first forays in to programming involved implementing Zeller's Congruence. Zeller's congruence is a neat calculation because it involves a mathematical approach to date manipulation, ...
I need to obtain all combinations of a String of length k from the given elements. For example, for char[] elements = {'a', 'b', 'c'} k = 4 the output should be: aaaa, aaab, ..., cccc. Now I have the following code which gives proper results BUT isn't fast enough. What can I improve in my code? public static ArrayLi...
I'm working with this query to get counts from three different tables, and to group the results by account ID: SELECT accountId , SUM(ApplicantsCount) as ApplicantsCount, SUM(ApprovedCount) as ApprovedCount, SUM(ScreenedCount) as ScreenedCount FROM ( SELECT application.accountId, COUNT(*) ApplicantCount, 0 App...
My brother bet me that I couldn't make a game in Excel. The code is all over the place and buggy in parts. But I would appreciate it if anyone would give this game a go. The music and the code has all been made by me, but the artwork was found online and I can't claim any of it is mine (although a few bits were photosh...
I am very interested in the Monte Carlo AI. I tried my best, still, this AI plays very badly. This code "works" in the meaning that it does not crash, but the quality of play is extremely low. Have I completly misunderstood the Monte Carlo AI or is there just a nasty bug in my code preventing it from playing correctly?...
I have this C# production code for handling errors on a web application. There are currently two applications that use the class. In each application I initialize the class within the Page_Init method in a base class that is used on every page. Some methods are used to actually display the message whereas other methods...
Here is a link to my problem $('#name').focus(function() { if ($(this).val() == 'Full Name*') $(this).val(''); }).blur(function() { if($(this).val() == '') $(this).val('Full Name*'); }); $('#email').focus(function() { if ($(this).val() == 'Email Address*') $(this).val(''...
A question on Stack Overflow recently intrigued me to the point of me implementing the functionality in C. Can you critique this algorithm and tell me what is good and bad about it? This program will tell you if a string is inside of another string. For example: "elf" would be inside "self" "hit" would be inside "chem...
After about half an hour of fooling around with Processing.js/JavaScript, I got this fairly decent particle system set up: // main particle constructor class var Particle = function(position) { this.velocity = new PVector(random(-0.1, 0.1), random(-0.1, 0.1)); this.acceleration = new PVector(random(-0.01, 0.01)...
I am just getting started with C and made this simple shell to test my understanding of some basic principles. The shell reads commands from standard input, forks itself and executes the command. How am I doing, and where can I improve? #include <stdlib.h> #include <stdio.h> #include <string.h> #include <unistd.h> #inc...
A while ago I was experiencing 'flakiness' on my home ADSL line. I run a Linux server in my basement, VOIP, and a few other things (like Netflix) and I was experiencing a few minutes of network downtime every few hours. This was dropping very important things, like the kids watching cartoons, and my phone-calls with my...
I have a small function that takes in a list of JSON objects that has the format below. The function below that wants to see if the brand and model of car passed to it can be matched against the List parameter called jsonfiltersList. The code I have works, but being somewhat new to coding and Java I wanted to know if I...
My UnitTesting add-in works nicely, but it has dependencies on a Reflection and a System add-in, which means 3 add-ins loaded into Excel to write and run a VBA unit test, and I've recently decided that was a pain in the neck and didn't quite make VBA unit testing, uh, very much appealing. So I proceeded to port my VBA ...
After reading about the composite pattern from Design Patterns, I thought to re-implement the code mentioned in the motivation section using the modern C++ concept/idioms: #include<iostream> #include<vector> #include<string> #include<memory> #include<algorithm> /*****************************************/ template<typ...
I have created a logger class for my own framework. Now I am trying to identify the components which can be done in a better way. The logger class doesn't log anything inside a file but it logs the files that are getting loaded (say controller, model, etc.) and displays it in HTML. I think it's bad practice to output H...
Here is my function I want to test: template<typename T> void free_items(std::vector<T*>& items) { std::for_each(items.begin(), items.end(), [](T* (&item)){delete item; item = nullptr; }); } I expect the each pointer in my result vector will be freed and be set null correctly. So I write down the following test co...