instruction
stringlengths
71
71.9k
I'm learning Swift and trying get a good understanding of some of its many features. The following is an AVL tree implementation with extensions that conform to SequenceType, CollectionType and ArrayLiteralConvertible Everything seems to work correctly. I wish to get some feedback on my overall approach, pointers on ho...
Input a binary tree (the root node) and 2 other nodes that need to be assessed for finding the least common ancestor (LCA) Code: a. Finding the nodes first with either breadthFirstSearch or depthFirstSearch b. If they both exist, find the LCA. What searching mechanism would be best here? Using breadthFirst for now. ...
import praw import time import database # Create a user agent and log into Reddit UA = 'OZBOZZ v0.1' r = praw.Reddit(UA) # Log UA into reddit with my personal user name and password r.login('', '', disable_warning='True') subreddit = r.get_subreddit('listentothis') current_time = int(time.time()) user = '' submission...
Input: Array of sorted integers and an element to check the frequency for Output: Frequency of the element public class FrequencyElement { public static void main(String args[]){ //System.out.println("Enter Input string"); int input_array []= {2,3,4,25,99,99,19000}; int element = 99; System.out.printl...
I am using below code and for result i am using interface for call back purposes. @Override public void onResult(String result) { if (this.mClient != null) { this.mClient.cancel(); mProcessing = false; } try { JSONObject j = new JSONObject(result); JSONObject j1 = j.getJSON...
I'm working on a report of quality control. I have a list L, which contains the names of files that I should open and import the data into EXCEL, then fill my quality control table by these data. And at the end, I want to know which file in the list has not been opened, that means this file (or this point of control) i...
I can't wrap my head around that. There seem to be a lot of redundancy, and even if it is not called called more than ten times in the main loop, I still find it hard to swallow that it loops through the whole list at each invocation. def get_file_info(f, stream, field): discoverer = GstPbutils.Discoverer() di...
My question is about this sort of table that's simplified here. Often, I find myself putting this element, (int (*)(const void *, const void *))&strcmp for bsearch. I go between prototyping with void pointers, creating dummy functions, and casting, but none is really a satisfactory, especially when the functions are co...
Problem from Hacker Earth: Inverted GCD: Given an array a of \$N\$ numbers , you have to find the number of pair of indices \$i\$ and \$j\$ that satisfy the following relation: \$i < j\$ \$a_i > a_j\$ gcd\$(a_i , a_j) = 1\$ Input: The first line of the input contains a single integer N - denoting the size of the ar...
After reading a bit about CSS3-text-shadows and seeing a few advanced examples I had the idea for a "neon light"-banner. Next idea was to animate it. Finally it has become a mixture between a Sass-mixins and a bit of JavaScript. One more thing I should mention: It's a fun-thing. I'm not intending to use it somewhere p...
The generic arrays in C I found on the net used either of these methods: The preprocesser with #define and #include (a lot of repetition and different names when declaring multiple types, but type-safe). void *-pointers (no type safety). void *-pointers and callbacks that fetch specific datatypes from the pointers (tr...
I have a table of groups, and a table of members. Each member belongs to one group. This is how it looks (more groups then 2 are possible): Groups id | name | year | ------------------ 1 | Nice | 1966 | 2 | Hard | 2012 | Member id | name | idGroup | ---------------------- 1 | Bernd | 1 | 2 | Max | 1 ...
This is an update from here. I have made some changes, and have decided to only include the UI side of things in this particular question. I wanted to make the application follow the MVVM pattern, but I have strayed in order to add functionality incompatible (or at least so I read) with the pattern. Synopsis This progr...
I want to create a function that filters a list with the following criteria: Strings containing numbers should be removed Strings containing only one word and first letter of the word is not uppercase should also be removed. Strings containing more than one word and first letter of each words except first word is not ...
I have this RPG game and this has elements such as the map, the monsters and the items. The monsters and the items are stored in Lists and every time I want to show the map around the player, I have to check if the element is within the bounds of the camera. public void ShowCamera() { int size = cameraSize/...
I have written a solution of a Mars Rover problem in C++ using OOP, but I am not fully satisfied with the design. What changes can I make to improve the design? Problem description is: A rover’s position and location is represented by a combination of x and y co-ordinates and a letter representing one of the four card...
This class is mostly an educational exercise for me using some C++11 constructs. I wanted to create something similar to an "invocation list" in C#, i.e., a list of zero or more function objects which should be called when the invocation list as a whole is invoked. I'm certain there's room for improvement here and I'm ...
I have the following code that I am trying to optimize. I am running it on a Linux machine with 24 cores. I thought I could use multithreading to make it faster, but it's somehow making it way slower than the single thread. I believe it is because of cache misses but I am not sure how to structure this code to avoid th...
I would like to be able to set token values (defaultFieldSet.tokens) and names (defaultFieldSet.names) on org.springframework.batch.item.file.transform.DefaultFieldSet using a java.util.Properties object. Specifically, the keys of the Properties object will serve as the names and the corresponding Properties values wil...
The challenge is to calculate the sum of the first 1000 primes. The code applies a sieve thanks to past answer, here, and works but I wonder about the flexibility of this solution. #include <stdio.h> unsigned long compute_sum_of_primes(int primes_needed) { int sieve_size = 20 * primes_needed; int sieve[sieve_s...
I'm not happy about my code, but is the better way that I find, I'm not happy because I see that there are many code repetitions and when any change is easy to make mistakes. Do you think you can do better? Any suggestions are welcome Sub ConvDateD(c As Integer) Application.ScreenUpdating = False Dim lrw As Long, i As...
I have a problem with my code. I made so much code, and now I need to place ends, which I cannot figure out how to do because I need to line everything up and then place at least 5 or 6 ends in the right places. I am fairly new to Lua and I'm sure that there's a better way to go about this, so if there is, tell me in ...
I have code that opens a workbook and copies the sheet to the workbook running the code. I know activating is generally bad for speed but I can't figure out how to speed this up anymore. The data area is usually "A1:Q45000" but is different all the time. Sub AutofillOperations() Dim answer As Integer, fd As File...
I wrote a Matrix struct and a neural net that uses it. Why is this slow? Gprof blames Matrix::operator()(int, int) which I suppose is my constructor, and Matrix::operator*(Matrix) and vector<float>::operator[]. #include <iostream> //#include <C:/Users/David/Google Drive/Coding/neural_c/Launcher.h> #include <fstream> #i...
I'd love thoughts on how to make this more elegant. I'm planning to add some additional functionality, but basically this is just my first pass at creating a pythonic Slack bot from scratch. You need Slack API token to run it. I am deploying to Heroku, so I have it looking for an environment variable called API_TOKEN ...
I have a working macro that finds a specific word and deletes the whole text. It finds the word "JOBSPECIALTYCODE" in the sheet, selects and deletes it, then moves to the next sheet. I just want to ask if there is any alternative way to make my macro work fast. I only use a record macro. Sub aHaveProgess() ' ' ' ' 'D...
For simplicity, it is checking whether the characters in a string (that needs to be created) are present in a larger string (dictionary). Would a character array of the letters make sense here, or would it be better with a Map<Character, Integer>? public class RansomNoteProblem { public static void main (String args[])...
I just finished a scraper in python using scrapy. The scraper logs in to a certain page and then scrapes a list of other pages using the authenticated session. It retrieves the title of these pages and puts it in a list of items together with the page name. Because there are little examples to find on continuing scrapi...
Here is my code that finds the number of digits in a given integer (either positive or negative). The code works and results in expected output. ''' Program that returns number of digits in a given integer (either positive or negative) ''' def ndigits(x): # Assume for the input 0 the output is 0 if(x == 0): ...
I have a MVC WinForms application. I am using Dependency Injection with Ninject as the IoC container. public class SqlObjectExplorerController : ToolController, ISqlObjectExplorerController { private ISqlObjectExplorerView view = null; private SqlServerStructureProvider structureProvider; private IProgress...
I have a matrix in which the right-most elements are repeated YYYYMMDD dates in descending order, for example: 40 1122 1711 20160326 169 700 950 20160326 40 1630 1711 20160326 182 700 950 20160327 40 1029 1711 20160327 169...
I am checking data output in some testing code, and only some fields can be None, but I think this can be better: for key in data[0].keys(): self.assertIn(key, data_model) if data[0][key] is None: self.assertTrue('rate' in key or 'percentage' in key or 'ratio' in key) continue ...
I am retrieving data from a json object and even though code works I am not sure if I am following best practices. In particular some of the objects seems too deep (like value.metadata.connections.comments.total) and not sure if there is a better way to avoid creating all my markup in JS. (function getData() { $....
I'm learning F#. The code below gets a number e.g. 100 and list of factors and should divide that number by the factors without any rest. (There is an actual code I've got in C#, but this is F# port). I especially didn't liked equalsDifference function.. any better solution? namespace RozbijaczApp module Rozbijacz = ...
I've written a home-grown solution for checking the status of my servers. This is both an exercise for me in learning further about Python, but it's also critical to status-checking critical things on my "network" of servers - both running against both an internal ("home") network against 18 or 19 VMs internally I nee...
I have functions of permutation : function permutations($letters,$num) { $last = str_repeat($letters[0],$num); $result = array(); while($last != str_repeat($this->lastchar($letters),$num)) { $result[] = $last; $last = $this->char_add($letters,$last,$num-1); } $result[] = $last; return...
I'm learning Python. I'm making a random animal generator, from 5 txt files. Each file is a list of words for respectively the specie of the animal, an adjective, an origin, and a bodypart with a color. Not all may appear in the description. I also wanted it to be arithmogrammatic. Here is my code, I know it can be imp...
I'm computing the crc32 of a given file using boost: uint32_t crc32(const std::string &fp){ boost::crc_32_type result; std::ifstream is{fp, std::ios::in | std::ios::binary}; size_t file_size = is.tellg(); is.seekg(0, std::ios::beg); std::vector<char> buf(file_size); is.read(&buf[0], file_size); ...
I have solved the following problem. My code works but Hackerrank says that I can do faster: There are plants in a garden. Each of these plants has been added with some amount of pesticide. After each day, if any plant has more pesticide than the plant at its left, being weaker than the left one, it dies. You a...
I made this small Blackjack game in the past as a way to practice C++ basics and have fun at the same time. I stopped working on the game during the last two years of my computer science degree program and now in my free time I want to improve it. I'm looking for suggestions on how I can improve the game. Not just addi...
I'm trying to reproduce a gbm model which was estimated without a set.seed value. To do so I need to determine what seed was used, which I can figure out based on one of the summary metrics from the estimated model (as shown below). require(MatchIt) require(gbm) data("lalonde") i <- 1 while(!(tmp$rel.inf[1] == 82.34293...
I'm fairly new to Java. I want to divide my code into 3 classes. First class to contain my GUI, second to compute the algorithm and third class to write results in my file. I have the code working but I can't get to divide it in 3 separate classes. All i want to know is by example, how can i make parameter list that I ...
This project is ultimately my senior thesis to graduate from college. It will end up being very long with several code reviews and redesigns. The next rubberduck perhaps? I've been working on a project that tests awareness of phishing scams. It generates emails based on templates and sends them out to a database of ema...
I'm starting a new C projet and I want to have the cleanest and shortest error checking code possible. To that aim, I often use two things : functions return 0, false or NULL on error I try to use small functions with one cleanup label "fail" or "error" So I thought about using a macro to simplify the code even mor...
I recently answered a Stack Overflow question about transforming an array of Characters into a String in Swift. Looking at the question and the Swift standard lib, it appears that there is a method joinWithSeparator, but the current implementation only supports SequenceType instances where the Element is a String. As...
A while ago I asked this question Memoizing decorator that can retry and then promptly forgot about it. I more recently saw Python decorator for retrying w/exponential backoff and wanted to add backoff, but figured I should improve what I already have first. I have taken some of the suggestions of the original, but rea...
I recently had an interview and got to phase 2 which is a coding assessment. One of the questions was: Find the first non-repeating character in a string: ("DEFD" --> E) I didn't pass the coding assessment and was wondering if the community can help me improve. Solution: /// <summary> /// Assuming that lette...
This prime number library is one of my first programming projects I've done in c++. My goal is to create useful functions that deal with prime numbers in an efficient way.Note: (Most of the functions used are powered by the sieve of Atkin) I'd like to know any sort of optimization or better code practices that I should...
I followed the tutorial Build a PHP MVC Application and have implemented a database connection. I made a seperate database connection class and I call it in the controller. It works, but now I have to inject it whenever I call a method from the user model. Is this considered good (dependency injection) or bad (repeatin...
Exponential backoff in the context of various networking protocols looks something like this: When a collision first occurs, send a “Jamming signal” to prevent further data being sent. Resend a frame after either 0 seconds or 51.2μs, chosen at random. If that fails, resend the frame after either 0s, 51.2μs, 102.4μs...
I recently had an interview and got to phase 2 which is a coding assessment. One of the questions was: Given an array with 1,000,000 integers between 1 and 1,000,000, one integer is in the array twice. Find the duplicate. I failed the interview and was wondering what improvements do I need. /// <summary> /// Assuming...
I'm working on a function that returns a specific set of times for a given timezone and a given frequency; day, week, month. For any given timezone and a frequency the function will return the unixtime hour start and unixtime hour end of the last full frequency given. For example, the last full day, the last full 7 d...
I recently developed my first appwidget for Android, and it works really nice. I basically created a collection widget and use a Loader to retrieve the data from a database, and when a user clicks on the list item, that items details will be saved into a bundle in an intent, and the main activity will be launched with ...
I'm in the process of writing a python script for automating a data ingestion pipeline using Amazon Web Service's Kinesis stream, Firehose and lambda. This is my first stab at writing Python, but I do have some experience with JavaScript and Node.js. Scripts are organized as follows: build_pipeline.py - this is where ...
There is no input validation for this, but that aside, I would appreciate it if anyone could help me improve the logic of this script. import math #Input num = input("Enter a whole number: ") #Floors input in case of a non whole number decimal = math.floor(float(num)) #Variables exp = 0 divTwo = 1 zeros = 0 total = "...
I heard/read that writers of texts can be recognized by counting their used words and compare these to previous works. As a code kata I experimented with this a bit and found some disturbing facts. 'Romeo and Juliet' was written by one of the Bronte sisters. Shakespeare plagiarized it from the future. My program is n...
I'm starting a new, small C project and would like to have the safest, cleanest and shortest error handling code possible. Here is a comparison of different ways to handle errors in the same C function. Which one should I use and why ? The function, called db_create, creates a new ImageDatabase instance. Table Of Conte...
The send_sms_message method takes text as an argument. The length of text is unknown and can be 0 or as large as 1070 (after that we will have no space for the actual text, because multi-part message text will be so long). The trick is that if text is larger then 160 characters, we need to split it into parts and to ea...
I have created this macro and having a small issue. I am very new to this VBA and did this with experts’ guides by googling it. I am creating an excel form for a work purpose at work. The Excel form has 7 sheets and each have named tables with different data. 1st sheet is the editable form, which retrieves data from t...
Is it possible to reify the graph of lambda terms expressed as parametric HOAS. Not quite sure if it is data PLambda a where Var ∷ a → PLambda a Lam ∷ (a → PLambda a) → PLambda a App ∷ PLambda a → PLambda a → PLambda a newtype Lambda = Hide { reveal ∷ ∀ a. PLambda a} data PLambdaNode a n where G...
I'd like to get some feedback on my AVL tree implementation. I appreciate any comments related to style and performance, particularly if something can be written in a more concise or idiomatic way. If you see a way to refactor delete into something shorter and with less repetition, please let me know. I am also interes...
I wrote this code over the last few days and I learned a lot, and it works as I expect. However I suspect it's woefully inefficient: import requests, bs4, os os.chdir('../../Desktop') wallpaperFolder = os.makedirs('Wallpapers', exist_ok=True) pageCount = 1 GalleryUrl = 'https://wall.alphacoders.com/search.php?search=...
I have been using Python 3 to learn programming, and this is a very basic task, but I want to gain good programming patterns/habits at the very beginning. The program will first randomly generate a number unknown to the user. The user needs to guess what that number is. The program interacts with the user. import rando...
I have a set of images with class = tt like so: <img src="images/arc_unselected.png" title="Arc" class="tt" /> and I have written this code to change the images after clicking: $(".tt").click(function(event) { var title = event.target.getAttribute("title") resetOther...
I'm using a selfmade python program for learning new words in new languages. Originally I made this program for a university course but now I'm just trying to imrove it and make the code "prettier" and perhaps some small functionality improving. :) The basic principle is that the program reads from a file the foreign w...
I tried the module pattern for the first time, with this exercise as a problem to solve: http://exercism.io/exercises/javascript/grade-school/readme It's a small exercise requiring simple tasks : Add a student's name to the roster for a grade "Add Jim to grade 2." "OK." Get a list of all students enrolled i...
Can you check my code if I wrote like a professional? connection page. form sign page. plan page. log out page. First I create the database and tables, then the connection file, then the form sign in page, then the plan page, finally the log out page Database educate (create table users): CREATE TABLE users( id INT A...
Suppose there is an array A = {3,2,5}, then points for this array correspond to indexes (i,j) where i <= j = {(0,0), (0,1), (0,2), (1,1), (1,2), (2,2)}. The program returns max(sum) such that sum = A[i] + A[j] + (j - i). For the above array : point (0,0) will have sum = (3 + 3) + (0 - 0) = 6 point (0,1) will have sum ...
I just had the idea to develop an algorithm to calculate and highlight the difference between two strings. I know that there are already some libraries to do the job but I just tried to make my own. I really don't know whether this one is similar to the existing ones but it seems to work fine. As of now it's still in i...
The following code is not one of my proud moments. In its initial state, I had only a single purpose, but know I'm up to three purposes and I don't know if it would stop there. I'm using mailin.io to forward mails to my endpoint as JSON data. There are three main purposes, I've tried to describe it as best as I could ...
I have a small application that checks some system status and display it details. I have the following code which is working. But I want to make sure it's optimal: public partial class MainWindow : Window { // Dictionary to hold info Dictionary<string, int> dataHolder = new Dictionary<string, string> { ...
I need to run a sequence of runnables on the main (ui) thread with a given delay between them indefinitely until signalled to stop. Code: public class UiLoop { private Handler h; private AtomicBoolean breakLoop; @UiThread public UiLoop() { if (Looper.myLooper() != Looper.getMainLooper()) { ...
The method medianOfThree returns the median of the first, center and last element in array sorts the first, center, and last element of the array, so they are in order EXCEPT places the center in the second to last position. Examples: INPUT: 1,2,3 RETURN:2 EFFECT:1,2,3 INPUT: 3,2,1 RETURN:2 EFFECT:1,2,3 IN...
I have the following piece of code: for (var i = 0, len = legend.allItems.length; i < len; i++) { (function (i) { var item = legend.allItems[i].legendItem; item.on('mouseover', function (e) { var posLeft = 0, posTop = 0, parentWidth = chart.chartWidth; ...
I have a case class that is recursive and looks like this: case class Config(name: String, isEnabled: Boolean, elems: Map[String, MyCase]) case class MyCase( id: String, isActive: Boolean, elems: Option[Map[String, MyCase]]) Where the Config contains the id of the MyCase entries contained as a Map. I have to it...
I got this out of an article on interviews / code challenges. The challenge text goes like this: A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward. Allowances may be made for adjustments to capital letters, punctuation, and word dividers. Examples in...
The problem Project Euler 1 is one of the most asked questions on site. However I wanted to solve the more general problem of division. Multiples of a list If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multipl...
I have a question concerning the correctness of the reading and displaying the image in ASP.NET Core MVC web application. This is the way I am reading image names from a specific folder (I am using IHostingEnvironment _hostingEnvironment to get the rootPath): public class GetRandomImageForGalleryView : IGetRandomIma...
Introduction In template meta-programming, integer sequences and ranges are very useful. I've made a couple of utility classes that do various operations on compile-time integer packs. The implementation is non-recursive (except for \$log(n)\$ recursions when generating a pack), allowing faster compilation and a greate...
The challenge is to find and print the largest palindrome prime under 1000. def reverse(integer): result = 0 while (integer != 0): result *= 10 result += (integer % 10) integer //= 10 return result def is_palindromic(integer): return integer == reverse(integer) def produce_sie...
This code gets a list of signals with predefined frequency from struc.num I need to encode it to wave format, so i use this code. This works, but i dont sure it is a correct decision to encode like this in python. Is there any ways to do it better? def compiler(): import out print("Loaded out.py") print("C...
I have a simple class which holds my product. Someone can add a serial to this product and also a purchase id. On change of the properties, I want to check whether both properties are set, and get the license class and add it to the product. public class License { public bool IsTrial { get; set; } public bool ...
Could anyone tell me if this code is well written and if it has bugs / vulnerabilities? class.user.php: <?php class User { public $authorized = false; public $uid; public $username; public function __construct() { $this->db = new PDO($dsn, $db_user, $db_pass); ...
I have finished my first project for Python. I would be very grateful if you could check it and give me some feedback. Just simple game with possibility of replay. There are probably lots of mistakes and code could be half the size, but I just started with programming. I tried this game on a few computers and unfortuna...
This allows me to search each cell J4:J6525 in range K4:K6525. If it is found it will paste the values in Offset(0, 2) (column M). I run it for files with more than 60000 lines, and sometimes much bigger. It takes a long time to complete. How can I make this run faster? Sub Finder() Dim WhereToSearch As Range, WhatToS...
In the C# Player's Guide book there's a challenge in which you have to write the PigDice game in C#: It's a multiplayer game, every player starts with score 0. Player X rolls 2 dice. Player X's score is increased by the sum of the 2 dice' numbers. If Player X gets 1 on either die, his score becomes 0 again and it's t...
I have written a constexpr sin function using c++14 and would like to know what I can do to improve it. I am trying to balance code clarity/maintainability with performance. My goal was to have every part of the algorithm that does not depend on a run-time parameter be evaluated at compile time. #include <type_traits> ...
I'm sure there is a better way to implement this feature. I am making an app that allows a user "upvote" or "downvote" a post. Right now, the code works and disables the upvote button if pressed and vice versa with the downvote button (the idea is that a user can only upvote or downvote once). post.js import React, { C...
To start off I'd like to note I am aware of int(val, base). My goal was to write a short function capable of taking in a base int, and a string defining the value to be summed. The function rests upon the equation: represented_value = value * base ^ placeholder >>> base_v = lambda base_v, num_a: sum(int(num_a[len(num...
This is a game about matching the right colour. In the first level you start with 3 cubes that each have a different colour. After 2 seconds the colours of the cubes disappear and the cubes become white, so you need to remember the colours of the cubes. Above the cubes you have coloured circles of the previous colours ...
This program was written on Windows 7 using Visual Studio 2012 Professional. Some of the issues encountered may have been fixed or changed in a more recent version. This is a quote from my second question in response to a comment made below: The algorithm in KnightMovesImplementation.cs implements a recursive tree se...
Was just wanting some general feedback on the below code regarding 1. Readability 2. Structure 3. Efficiency import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Scanner; /** * Created on 5/27/2016. * * Simple functions used to reverse either a sentence or a word. */ ...
This is for a client of mine: Enbridge Gas. I had to turn 2 .psd file into html and CSS. This client is my first real client by myself and I want to make sure my code is improved as much as possible. I would love feed back on my style, naming conventions and ect to improve the code. If you'd like to see the full projec...
I was inspired by this Reddit /r/dailyprogrammer challenge: Contrary to popular belief, the tetromino pieces you are given in a game of Tetris are not randomly selected. Instead, all seven pieces are placed into a "bag." A piece is randomly removed from the bag and presented to the player until the bag is empty. When ...
Task: Given a set of points on a line and a set of segments on a line. The goal is to compute, for each point, the number of segments that contain this point. Input Format The first line contains two non-negative integers \$s\$ and \$p\$ defining the number of segments and the number of points on a line, respect...
I have a small program in Java with GUI, which is showing NBP currency data in specified tabs. It downloads data from www.nbp.pl using XML format and saving it into Apache Derby database using hibernate. I am posting my code here because I want to correct myself in style and, eventually, in efficiency of writing code. ...
I am trying to create a Data Access Layer using ADO.Net. I have created a generic method for ExecuteNonQuery. The stored procedure I am calling will return two parameters. The output parameters from the stored procedure should be assigned to DTO object and the DTO should need to be returned to BLL. I am a bit concerned...
I've created a working Android app for my project website. I'm newbie too android dev so please review the code of this app. Any simplification or suggestion to optimize it much appreciated. Thank you. MainActivity.java public class MainActivity extends AppCompatActivity implements MyWebChromeClient.ProgressListener { ...
I just decided to get a bit more acustomed to using templates. Maybe this is a stupid question, but in my experience in C++ there is always some pitfall lurking aroung the corner. Thus I prefer the danger of embarresment instead of building up on bad habbits. Mainly as an exercise I wrote this: #include <functional> #i...
I've written a ISBN-validating annotation. It is to be used in conjunction with Hibernate Validator. I'm pretty satisfied with this code as it works as expected, but I've had to make a design choice that I totally dislike. This is why I post this question. The method checkISBN returns an Optional regarding the error re...