• Breaking News

    Saturday, August 25, 2018

    When implementing new features that are similar to other features, do you make the older features more generic? Ask Programming

    When implementing new features that are similar to other features, do you make the older features more generic? Ask Programming


    When implementing new features that are similar to other features, do you make the older features more generic?

    Posted: 25 Aug 2018 05:23 PM PDT

    This may come off as a bit confusing, but it's a question that I keep finding myself asking as I pile on more and more responsibility to older systems and features that I designed previously. Trying to get to the gist of my question is a bit difficult, but I'll try to illustrate it with some examples.

    A couple of years ago, I was tasked with creating a highly customizable menu editing system for our site. This menu editing system was designed with one very specific purpose, and that was to allow end users to configure custom navigation menus for specific user roles in the system. The system wasn't overly complex, or overly robust, but it was functional enough to handle every possible use case we could imagine for creating a new navigation menu. We built all of our custom logic and special handling in. We wrote hundreds of lines of code to suit our specific business rules for this piece of functionality, and we shored it up.

    About a year after building the site menu system, I was tasked with developing a dynamic menu system for our mobile application that allowed us to create custom menus based on the company that the user worked for. This new system was very similar to the old system, and we decided that it was best to reuse the site menu tables and functionality. All we needed to do was expand them slightly, and they mostly suited our need. However, there were still some major differences, those were:

    • The mobile menus did not exclusively use Font Awesome as their icon like our website menu did. Instead, it used images that it fetched from a static location on our web-server. It also allowed custom images to be uploaded and stored in the database. So now we needed to check if this mobile menu item populated the url field or the file field.
    • The mobile menus were based off of the user's company rather than their assigned role in the system. This rendered our MenuRoles table useless for this function.
    • The mobile menu didn't navigate to different pages on our website. Instead, it corresponded to certain actions in the application, but it could also launch a webview for a custom URL. We mitigated this by making an actions table and including a URL field.

    Now, to avoid cluttering the main menu table with excess columns, I built another table called MobileMenuItem that referenced our MenuItem table. This mobile menu item table housed all of our extra columns, and we simply put in code to ignore the irrelevant columns in the original MenuItem table. Not too big of a problem.

    Next we had to update how the menu permissions were checked. Fortunately, over the last year, we also built an incredibly robust FeatureSet function that can hierarchically check through many many different scenarios to determine which features an individual user had access to. Unfortunately, it was originally designed to simply determine if a user had access to a specific feature. These features were simply a string in the database that we accessed through constants in the code, and the algorithms we put into place merely spit out a true/false as to whether a user had access to that feature.

    Fortunately, a few months prior, we had customized the feature set system to be able to fetch strings from a resource table based on which features a user had access to and which individual features had been overridden. But again, this system wasn't quite the right fit for fetching the proper menu as we were fetching strings, not menu references. So again, we adapted the system to be able to handle menus as well. Again, disregarding previously implemented features and having to code around what we had built before.

    In the end, this lead to a series of 3-4 unrelated systems that were just similar enough to reuse some portions of their functionality, but we broke the specificity of those systems in the process.

    So I'm sitting here today, building a 3rd Menu Editor that customizes the home screen of our site based off of custom companies (much like the mobile application). However, it is just different enough that I have to modify the original MenuItem table to include many properties that were included on the MobileMenuItem table. So now I'm left with 3 unrelated menu editors with columns that are ambiguous between tables, logic that is specific to each individual system, and spaghetti code as far as the eye can see.

    So my big question basically boils down to, what is the right approach? Should you completely decouple your features of your application, even though they are incredibly similar? Should you basically have potentially dozens and dozens of nearly identical tables and algorithms even though they they are only just slightly different.

    Or, should you attempt to reuse as much of your other systems as possible?

    submitted by /u/jdsfighter
    [link] [comments]

    Basic C++ question - How to read/parse command line input?

    Posted: 25 Aug 2018 06:22 PM PDT

    Feel free to skip past the solid line if you don't need background information

    I tried searching, but I don't think I'm phrasing this properly. I just participated in my first coding competition and did not get a single point.

    Not because I did not understand the problems. I've done plenty of online stuff (Google, Codewars, Project Euler, CTFs, etc.) and had algorithms planned, but I absolutely fail at basic IO.

    Never once have I had to read from the command line, especially in the way they mention.

    Below is a transcript of what an example problem might look like. I've taken care to change the values in case someone else runs into something similar.

    The first line will contain an integer, n (1<=m<=1000) representing the number of orders in the record

    Each order will be contained on a single line

    • The first token of each of these lines will be an integer, o (1 <= o <= 10) representing the number of items on this order.

    • The items will be names of 1-30 lowercase characters. Items names are separated by spaces, and there are no other characters on these lines.

    This is an example of what I am trying to figure out with the question below.


    In C++, I do not understand how to read an unknown number of lines from the command line and parse them into usable data.

    This data can be a combination of letters, words, and numbers.

    In Python I would just read the line and .split() it into usable lists. In C++ I am much more used to accepting function arguments, not reading lines.

    1. How do you read a variable number of lines from the command line within your main function?
      • Do you just loop through n number of times for each, using getline() to read from the console?
    2. How do you parse these lines into usable data, as a general rule? (space/comma delimited is most common)

    Any advice on how to do this, or better yet what I need to research to learn more is greatly appreciated.

    submitted by /u/SquareInspection3
    [link] [comments]

    Java Help

    Posted: 25 Aug 2018 09:30 PM PDT

    I'm using eclipse but every time I try to run it says must declare a package name? I'm new to programing and would appreciate the help.

    submitted by /u/June56
    [link] [comments]

    Why do big companies not implement obvious features?

    Posted: 25 Aug 2018 08:05 AM PDT

    So I had this question for years now, basically since I started gaming. So basically the title, I'm talking about really obvious features/bugs/etc. Some examples: -Epic games made a launcher that has literally no way of detecting your game if you copied it from other hard drive. -epic games doesn't allow you to download fortnite from their site without logging, you can however get to download section by googling "fortnite download" -On GTA V online if you want to join a lobby the game will unload your character from map first and then check if the lobby is full or not, usually to say it's full and load you back into same place -on league of legends the shop where you buy currency fir real money is probably the most bugged and slow thing in entire game, making it really annoying while it's company main source of income

    I always thought that its lack of player feedback and not experienced testers but when it happens in such big companies I think it's almost impossible. So I came here to ask: is it because it's hard to implement something to a huge game like GTA without also adding a lot of bugs or something?

    submitted by /u/ninoski404
    [link] [comments]

    Multiple values in header error; Websockets/expressJS

    Posted: 25 Aug 2018 01:36 PM PDT

    Hello friends. I am trying to configures a node server utilizing websockets. I am currently getting the error (when making requests from Chrome):

    Failed to load http://localhost:8081/socket.io/?EIO=3&transport=polling&t=MLoo3fH: The 'Access-Control-Allow-Origin' header contains multiple values 'http://localhost:3000, *', but only one is allowed. Origin 'http://localhost:3000' is therefore not allowed access.

    I've tried quite a few approaches with the cors library. I also tried using Firefox instead of Chrome for testing. This resolved this issue, but resulted in websocket messages that had no data in them. Im unsure if this is the same or a different issue. From my research, headers are set on the server side, but I am not sure how it is managing to get multiple values.

    My server code is:

    var app = require('express')();

    var server = require('http').Server(app);

    var io = require('socket.io')(server);

    io.set('origins', 'r/u/http://localhost:3000');

    var passport = require('passport');

    var LocalStrategy = require('passport-local').Strategy;

    var express = require('express');

    var session = require('express-session');

    var cors = require('cors');

    var MongoStore = require('connect-mongo')(session);

    var bodyParser = require('body-parser');

    var mongoose = require('mongoose');

    var cookieParser = require('cookie-parser');

    mongoose.connect(process.env.MONGODB_URI);

    var Models = require('./models');

    var apiRoutes = require('./routes/api.js');

    const whitelist = ['r/u/http://localhost:3000'];

    const corsOptions = {

    credentials: true,

    origin: (origin, callback) => {

    if (whitelist.includes(origin)) {

    return callback(null, true);

    }

    callback(new Error('Not allowed by CORS'));

    }

    }

    app.use(cors(corsOptions.AllowAll));

    app.use('/api', apiRoutes);

    app.use(cors('AllowAll'));

    server.listen(8081);

    io.on('connection', function(socket) {

    console.log('connected to socket')

    socket.emit('connect', {a: 'connected to server'});

    socket.on('cmd', function (data) {

    console.log('cmd', data);

    });

    socket.on('room', function(data) {

    socket.broadcast.to(data.doc).emit('joined', data.user);

    socket.join(data.doc);

    });

    });

    app.set('port', 8080);

    app.listen(app.get('port'), () => {

    console.log(`Server is running on port ${app.get('port')}`)

    })

    submitted by /u/MeanwhileAfrica
    [link] [comments]

    Pairing two notepads?

    Posted: 25 Aug 2018 04:13 PM PDT

    How can I pair two notepad files such that they are linked like this:

    info1:info2

    Belonging to notepad file 1 and notepad file 2, respectively.

    Thanks.

    submitted by /u/Apfelgold
    [link] [comments]

    How could one leverage his programming skills to start a small business?

    Posted: 25 Aug 2018 03:36 AM PDT

    I am a junior android & ios app developer with some back-end skills, employed 9-5. I was thinking about possibility to open a small business, but at a first glance I think, that economically I am way better being an employee in SW development company both on long and short term.

    Here are few remarks that I came up when considering B2C product development:

    • there are way too many apps in ios/android market, which makes me believe that it's very, very hard to sell a product there
    • most of apps don't make any money or at least don't make any serious money
    • product development cycle is utterly long and hard
    • From the aforementioned points it may be concluded that risk/reward ratio is pretty bad

    And few remarks when considering B2B product development perspective (service):

    • to be able to acquire clients, one needs a good portfolio with good names on it
    • to be able to acquire at least first client and build up a complete solution that is usually required, an ACTUAL expertise is needed. I've checked few profiles of companies in the business and they are all consisting of teams of seniors with years of experience and specialization (for instance, a team consisting of software architect, android developer, ios developer, UX/UI designer, front end developer, back-end developer, an IT expert...was pretty usual setup even for a startup company)
    • again, emphasis on complete solutions - not only a new website, but a new website with iot/cloud sh*t , the accompanying smartphone versions and whole new back end system. Madness.
    • apparently when doing service business, it's all about portfolio, at least few year's technical know-how , experience and specialized teams. It's all about being able to deliver and deliver it on time. I feel that in this business there is no space for "two-guys-in-garage" companies.

    And the consultancy business (service)

    • One probably needs to be one of the best in the field with vast experience and expertise. I believe that half a decade working in specialized field may be a pretty much real estimation.

    Of course there is also upwork/fiver and similar stuff but that's a joke. Competing with developers from China who do stuff for small money is not an option. I can get better paid way better as 9-5 developer.

    submitted by /u/ExpressGroup
    [link] [comments]

    Quick C++ question

    Posted: 25 Aug 2018 01:38 PM PDT

    The program I am writing will be executed with:

    ./hw1 <p.alpha

    where p.alpha is an alpha file with various lines of text. I get that the arrow will feed the file into the program, I just don't know how to use any of the data. It doesn't seem to count as an argument. but I'm not positive. I'd like to google it but "C++ sideways carrot file into program" sure doesn't help at all.

    submitted by /u/EightOffHitLure
    [link] [comments]

    Should I do Edx courses after beginner level python?

    Posted: 25 Aug 2018 12:32 PM PDT

    So I completed python beginners course but it didn't go too deep, will I be able to do intermediate level edx courses or will they be too difficult?

    For reference I did my python course from here: https://www.youtube.com/playlist?list=PLBZBJbE_rGRWeh5mIBhD-hhDwSEDxogDg

    And I'm looking at this course: https://www.edx.org/course/introduction-computational-thinking-data-mitx-6-00-2x-6

    Or this one: https://www.edx.org/course/using-python-for-research

    submitted by /u/punchingwater22
    [link] [comments]

    How to add a video to a playlist using Python?

    Posted: 25 Aug 2018 07:47 AM PDT

    Can anyone point me towards a tutorial that will show me how to log into CollegeBoard using python on a raspberry pi

    Posted: 25 Aug 2018 07:39 AM PDT

    Blocking 1st party scripts won't bypass copy paste restriction on this website

    Posted: 25 Aug 2018 04:53 AM PDT

    https://www.uworld.com/NCLEX/Demo/RNTest.htm

    What is the method they used to block copy paste? and how to bypass it?

    submitted by /u/0xcha1n
    [link] [comments]

    Building a website for a friend with a domain name

    Posted: 25 Aug 2018 04:28 AM PDT

    Hey all!

    So long story short a friend of mine has a small business website with some very basic information. No signups or purchases just information. I believe he is currently using netregistar for the domain name and possible the website builder. Was wondering what the quickest way to through something together using basic html and JS is.

    I personally haven't built a website myself but have used html and js a fair bit. My idea of it is that you have the domain name and if you want to make you're own website you just write and upload you're files. Looking for anyone who has done something similar and has any advice.

    PS: Not looking to learn wordpress or using third parties (Unless completely necessary)

    Happy coding!

    submitted by /u/pd145
    [link] [comments]

    How easy is it for someone with no experience in PHP to change some text on a website?

    Posted: 25 Aug 2018 04:26 AM PDT

    Hi,

    I own a website which is written in PHP, on Nginx. I'm wondering how difficult it would be for me to make some minor changes such as changing the about page, the menu, favicon etc. with no experience in PHP?

    Thanks

    submitted by /u/cryptosite4sale
    [link] [comments]

    How do I secure the data of a database ?

    Posted: 25 Aug 2018 01:38 AM PDT

    Hi everyone,

    So basically I have this school project where I need to improve the security of an application. What I need to do is set up a WAMP server for the app, and then add a new security-oriented functionality.

    The sensitive data for this app is divided in two parts : sensitive files, and sensitive/personal data in the database. The files are already encrypted, but the data in the database is basically cleartext. I know encrypting a database is a huuuuuge mistake as it takes a disgusting amount of time to process each request, so what would be the best deal here ?

    P.S. : Another problem would be the following : the files are each encrypted with their own key, which is encrypted by the master key. Problem is : if the master key gets lost, all files are lost as well. What would be a handy way to improve the safety of these files ?

    submitted by /u/Jambzerino
    [link] [comments]

    Can't get simple auto clicker JS script to work

    Posted: 25 Aug 2018 12:51 AM PDT

    var button=document.getElementByClassName("button collect round-sm collect_all"); setInterval(function(){ button.click(); }, 1000);

    Is the script I have in tapermonkey, using it to auto harvest crops on http://game.reapublic.com. I'm pretty new to programming, what am I doing wrong?

    submitted by /u/unkelrara
    [link] [comments]

    No comments:

    Post a Comment