9 votes

Fortnightly Programming Q&A Thread

General Programming Q&A thread! Ask any questions about programming, answer the questions of other users, or post suggestions for future threads.

Don't forget to format your code using the triple backticks or tildes:

Here is my schema:

```sql
CREATE TABLE article_to_warehouse (
  article_id   INTEGER
, warehouse_id INTEGER
)
;
```

How do I add a `UNIQUE` constraint?

9 comments

  1. [7]
    Gyrfalcon
    Link
    This isn't so much of a programming question, but a career question that involves programming. Things have been a bit slow on these threads so I'll put it here anyway. I recently graduated from...

    This isn't so much of a programming question, but a career question that involves programming. Things have been a bit slow on these threads so I'll put it here anyway.

    I recently graduated from college with a degree in an engineering field. Due to personal reasons, I'm in a bit of a job limbo, and will continue to be for a few months. I would like to use some of this time to build up a portfolio of work to try to convince people to hire me for a programming job in my field instead of someone with a CS or CompE degree. I'm not sure what to put in this kind of portfolio. I have written a good bit of code but most of it has been MATLAB scripts and the like for courses and I'm not really sure how impressive that is. I do have some ideas for what to put in a portfolio, such as:

    • I really enjoyed working on about half of this years Advent of Code before life caught up to me. I could finish that off and then go back and do all of the previous years as well. I like this because it gives me a steady framework, but I'm not sure if it would really impress anyone. I might do this for myself even if it's no good for a portfolio because I like puzzles :)

    • I have a bunch of random ideas for things I think would be cool:

      • A program that will solve Sudoku puzzles, and generate new puzzles and let you solve them
      • A little pomodoro timer applet, potentially combined with a time tracker and some kind of productivity gamification like Forest
      • Algorithmic trading on the foreign exchange markets. This is something I have already dabbled a little bit in. I think regulators don't like it so much if you make the code for it open source, so I'm not sure how easy it would be to show off.
      • A little simulation that shows the interplay between creating space for cars and walkability in an urban setting.
      • A model of a power grid with homes both consuming and producing power. Not really sure what to do with it once it has been modelled but it would be cool, I think.
      • A little WWI trench battle game, where you see how the technology of the time encouraged defensive warfare and led to the stagnation and entrenchment seen on the Western front.
      • An open source journaling application, because I saw a neat application and it was expensive and not for my platform.
      • Implementing more of my coursework in Kerbal Space Program. I have already pursued this a bit, sending a mission to the Mun and back autonomously. Next would be adding observation stations and determining spacecraft state from noisy measurements. It's really fun, but I don't think anyone really takes me seriously once I mention Kerbal, so ???
      • Something with peer to peer ebook lending, although copyright law makes this weird and maybe useless.
      • Some kind of distributed learning system using git, where the readme is the first lesson on how to get Python or something set up, and then the rest of the lessons teach you different things using the available source files.
    • I do have a website, but if has more of a sustainability focus. I might do some programming projects though, like taking worksheets from old solar power books and making them into command line or GUI programs.

    There are some ideas I have thought about but am kind of intimidated by right now:

    • Contributing to an existing open source project. Whenever I think about this I get pretty overwhelmed. If I have only ever gotten a few hundred lines to play nice together, how can I parse through thousands of lines to understand what's going on before even adding a feature of my own? I also find I have to comment my own code quite a bit more than others so I'm not sure if that's good or bad.
    • Convincing someone on a low price freelancing platform to hire me. This is good because I could make (a little) money, and someone else comes up with the ideas. I am concerned that if I dip my toe in too early and get bad reviews from early projects I may have a tough time getting more assignments.

    Anyway this has turned into a bit of a rant so if you happen to read some or all of it and/or provide any advice on the subject, thank you!

    6 votes
    1. [2]
      unknown user
      Link Parent
      Not sure if that's what you need, but James Hague of the Programming In The 21st Century fame argues that CS should only be offered as a minor. His point, on which he elaborates in other posts, is...

      Not sure if that's what you need, but James Hague of the Programming In The 21st Century fame argues that CS should only be offered as a minor. His point, on which he elaborates in other posts, is that doing programming for programming's sake and being in love with a technology won't get you anywhere, and instead you should always think of the task you're solving with the technology.

      So, a piece of advice that you may consider is finding a possibly non-technical domain that interests you and in which you could see yourself working, and then trying to solve a programming problem in it. E.g. creating something like an IMDB clone if you like films or a music player/equaliser/synth if you like music.

      6 votes
      1. Gyrfalcon
        Link Parent
        Hmm probably my biggest non STEM interest is history, and I think I could make some of the more gamey ideas I've had fit in with that as teaching tools. I do think the advice to not major in CS is...

        Hmm probably my biggest non STEM interest is history, and I think I could make some of the more gamey ideas I've had fit in with that as teaching tools.

        I do think the advice to not major in CS is an interesting one. That said, my goal is to eventually apply CS to the technical field I have my degree in, so I'm not so sure the non-technical domain bit fits 100%, though I'm interested to try it out. Thanks for the perspective.

        3 votes
    2. [2]
      spit-evil-olive-tips
      Link Parent
      This is my go-to "learn a new language" project, and would make a great portfolio entry. You can go quite far with it, such as implementing arbitrary-sized boards (9x9, 16x16, etc...here are...

      A program that will solve Sudoku puzzles

      This is my go-to "learn a new language" project, and would make a great portfolio entry.

      You can go quite far with it, such as implementing arbitrary-sized boards (9x9, 16x16, etc...here are example 49x49 and 64x64 puzzles to use as test cases) or implementing more complex solving algorithms such as X-Wing.

      Randomly generating puzzles is another can of worms...it's fairly easy to generate a filled-in puzzle, then remove squares. The tricky part is a) ensuring that you still have only one valid solution and b) estimating the difficulty required to solve the puzzle, so your generator can have easy vs. hard vs. diabolical options.

      4 votes
      1. Gyrfalcon
        Link Parent
        I think I will probably start with that, since it's a project I've been meaning to do and have dabbled in a bit already. Thanks for the advice!

        I think I will probably start with that, since it's a project I've been meaning to do and have dabbled in a bit already. Thanks for the advice!

        1 vote
    3. [2]
      happimess
      Link Parent
      When I'm interviewing a software candidate (especially one who is new or from an unconventional background) I'm mostly interested in seeing if they're smart, competent, and easy to work with. For...

      When I'm interviewing a software candidate (especially one who is new or from an unconventional background) I'm mostly interested in seeing if they're smart, competent, and easy to work with.

      For smart and competent, you'll need to show that you've done real work on a software project, and thought about the decisions and trade-offs you had to make in the process. Any of the projects you listed seem reasonable for this; it's more about how you build it and how you talk about it than about the actual app. Personally, I'd do Advent of Code (because it's fun and covers a lot of ground) and really devote myself to good practices. Taking 2019 for example, I'd write a solid 'intcode' library with unit tests and a clean API, and then reference it from all relevant problems. That's a solid medium-sized chunk of software engineering, and plenty of fodder for an hour-long technical interview.

      For easy to work with, you'll just have to demonstrate that you can cooperate and take criticism and explain ideas; there's lots that goes into it, but it will transfer well from whatever else you've been doing, unless you're a jerk.

      I'd caution you against doing cheapo freelance projects. First, you'll spend a lot of time doing client management, and unless you want to go into freelancing long-term that may not be a great use of your time. Second, you'll likely sign away rights to the code you've written, so when you start interviewing for other jobs you'll be have to talk about the project without showing any code.

      If you want to dive in to open source contributions, start by looking through a project's github issues; there's probably some low-hanging fruit in there that you could fix and get merged. A well-written bug report should also help you avoid the "how can I parse through thousands of lines to understand what's going on" paralysis that you correctly anticipate.

      glhf

      2 votes
      1. Gyrfalcon
        Link Parent
        Thanks for the advice! Advent of Code is definitely something I'm planning to keep working on. I was pleased with how my intcode stuff was turning out, though I only cleaned it up after I had to...

        Thanks for the advice! Advent of Code is definitely something I'm planning to keep working on. I was pleased with how my intcode stuff was turning out, though I only cleaned it up after I had to manage the amplifier challenge. Looking at issues completely slipped my mind when thinking about this, that's a great thing to consider too.

        1 vote
  2. [2]
    Kremor
    Link
    Is there a book for unit/integration testing best practices? I've been searching around and all I can find are books that focus on specific languages and frameworks.

    Is there a book for unit/integration testing best practices? I've been searching around and all I can find are books that focus on specific languages and frameworks.

    5 votes