Related
Let's say I wanted to make an app where people would ask questions and get questions, based on their responses.
What's an efficient way to do that?
I get the feeling creating many View Controllers is not the way I'm supposed to do it.
I'd like to know what I should do instead, or what concept I need to become more familiar with to implement something like this.
When you say "make an app where people would ask questions and get questions, based on their responses". you have a make a complex logic, there will be tons of If Else and lot more.
I suggest take a step back and start with something small. which doesn't require much complex logic, for eg. attached gif. simple storytelling app which "Show some content, answer some and get new question based on your answer".
Sample Image
I am looking to have a similar style of the table in the picture. I just do not know the code would make it in this way.
I know how to make table, but I do not know how would I make them in this way.
There's no simple answer to this question since it would take quite some time to create this entire table, which is a large commitment :-) If you're committed to it, it's worthwhile to understand, but you may want to begin with what you know and build off of it. Is there a particular part of this table that you are struggling with? Can you give us an example of how far you've gotten that we can expand on?
Here are a couple useful references that could help you get started:
A bit more about tables
A more advanced approach with different packages
I'm sure there are many others. Once you get started, try posting where you get stuck. I hope this helps!
How do I know if I am overanalysing?
I've been chasing a problem the last 3 days. I've been through many designs and reached a complex solution using about 3 classes. Having discussed with a colleague, I realized that all I need is one method and a struct. How can I avoid being an architecture astronaut?
I find that if I can't come up with a good clean solution in 30 minutes, it's almost always best to discuss it with someone else.
Even if they have no idea how to resolve it, it often triggers a better design or solution.
So talk to someone about it.
Personally, I can't really complain about anyone who actually PLANS their software first! I do this, but I know LOTS of programmers who only know how to just jump right into the code... and I often have to fix such code...
That said, what your really asking is how to know when there is a better solution to the problem.
The advice I have for you is to ask yourself repeatedly: Am I thinking about the details of my solution, or about the real problem?
The best way to avoid become an architecture astronaut is to get into the habit of jumping right in. The best way to jump right in is to write a few tests that will pass when your implementation is complete and correct. That forces to you confront what "done" means from the outset, and it provides a sanity check on the code that will follow.
Then head for a solution.
You might now get there the first time, but the exercise of starting with an idea of what "done" means firmly in mind will help you to ask better questions as you go, and having some acceptance tests done ahead of time will help cull the design space down to something reasonable.
I used to suffer from this problem. Designing a solution which could handle a lot of growth in the future and what not. Ensured it had good abstraction resulting in the type of concern you had above.
I then dumped this approach and whacked it all into one big dirty class maybe two. After that I re factored it until it resembled something I'd want someone else to work on.
I like doing something quick & dirty first, and when it works, I refactor the code step by step until I'm satisfied with the design.
This is also the TDD approach.
I find myself following these three steps to find an 'ideal' solution:
If I had all the time and resources in the world, what would be the best solution in any way. (Technologically, Logically, Performance-wise, optionally solving a few related issues, re-writing modules you find could do better...) Do your (over-)analysis here, just to get to know about as mush as possible. Run tests, statistics and create proof-of-concept's.
How is it different from the current situation. What is the difference between the results of the two solutions. Is there a faster way to get to the same or similar result. Why would this or that change solve the problem at hand. Do some more tests, statistics, update your proofs-of-concept.
Find a way to implement the required changes, and only the required changes, drop anything not essential to this change. Check you're not modifying anything that was not having the problem. Test this, review changes to code, logic, structure; and minimize them if at all possible.
This sounds very restrictive (and a lot of work), but in fact I find myself I end up adding an entire table to the database in some cases. Part of the work (because it's a lot of work to get 100% sure of something) is checking all existing code keeps working exactly the same with this extra table to join in.
To top that, in most cases here at work we need to cater for 'transitional data' that remains in the system from before the update, that will have to get produced and shipped all the same after the update.
There are some tasks, especially the ones that involve deleting folders as SU, that I do thoughtfully and slowly before I press the Enter key. I think if others saw me do these at the careful pace that I do they would cringe. Are there critical programming tasks that you perform that you believe deserve this thoughtful and careful consideration?
Changes to live databases, actually I do a backup first just in case even know I'm extra careful :)
It's kind of a programming task, because if I do it wrong, it will affect my ability to get paid for programming: Write emails on touchy subjects or to touchy people.
It can take me an hour to get the tone of a one paragraph email just right.
Anything that irrecoverably changes important data. I've learned my lesson the hard way, several times.
A release process is usually a methodical thing for me.
Everything. I've never been a "just dive into it" programmer. Always have, always will be.
Submits - 'cause its embarrassing if I break a test.
Code to evaluate the accuracy of something I'm developing. Otherwise, I spend all this time making the other code production-ready, only to find it doesn't compute the right thing after all.
Common code. I.e. changes to old, shared code which is used in multiple independent programs.
Kernel driver stuff - cause those blue screens are a pain !
Any collection juggling, especially in C (all it takes is one off by one error to shotgun your heap).
On the DB side, if I run an update/insert/delete and I don't want to backup the whole database, I always select * into myTable_backup from myTable
if make big changes in Visual Studio eg a big refactoring or maybe re-organising solution\project structure I will do it on a copy of solution first to see if there are any gotcha and that the bloody thing will still compile and play nice. Once satisfied this is the case I will do it on code under source control.
I do this because I have experienced situations where the 'rollback' functionality of whatever source control you are using won't let you rollback as required and\or does not get it %100.
Doing get from SourceSafe — really easy to hit a wrong button and lose your local version that you've been working on.
/I hate SS, but am forced to use it./
I took a data structures class in C++ last year, and consequently implemented all the major data structures in templated code. I saved it all on a flash drive because I have a feeling that at some point in my life, I'll use it again. I imagine something I end up programming will need a B-Tree, or is that just delusional? How long do you typically save the code you write for possible reuse?
Forever (or as close as I can get). That's the whole point of a source control system.
-1 to saving everything that's ever produced. I liken that to a proud parent saving every single used nappy ever to grace the cheeks of their little nipper. It's shitty and the world doesn't benefit from it's existence.
How many people here go past the first page in google on a regular basis? Having so much crap around only seems to make it difficult to find anything useful.
+1 to keeping code forever. In this day and age, there's just no reason to delete data which could possibly be of value in the future. Even if you don't use the B-Tree as a useful structure, you may want to look at the code to see how you did something. Or even better, you may wish to come back to the code someday for instructional purposes. You'll never know when you might want to look at that one particular sniblet of code that accomplished a task in a certain way.
If I use it, it gets stuck in a Bazaar repository and uploaded to Launchpad. If it's a little side project that pitters out, I usually move it to a junk/ subdirectory.
I'll use it again. I imagine something I end up programming will need a B-Tree, or is that just delusional?
Something you write will need a B-tree, but you'll be able to use a library for it because the real world values working solutions over extra code.
I keep backups of all of my code for as long as possible. The important things are backed up on my web server and external hdd. You can always delete things later, but if you think you might find a use for it, why not keep it?
I still have (some) code I wrote as far back as college, and that would be 18 years ago :-). As is often the case, it is better to have it and never want it, than to want it and not have it.
Source control, keep it offsite and keep it for life! You'll never have to worry about it.
I have code from many, many years ago. In fact, I think I still have my first php script. If nothing else, it's a good way to see how much you have changed over time.
I agree with the other posters. I've kept my code from school in a personal source code repository. What harm does hanging on to it really do?
I would just put it on a disk for historical sake. Use the
Standard Template Library - one mistake people make is assuming that thier implementation of moderate to complex data structures are the best. I can't tell you how many times I have found a bug in a home grown B-tree implementation.
Keep everything! You never know when it will save you some work. About a year ago I needed some c code to parse an expression, tokenize it for storage, and evaluate the results latter. Ugly little piece of code.. But is seemed familiar, as it should have- I had to do a post-fix evaluator in college (30 years ago)- and still had the code. Admittedly it needed a little clean-up, but saved me a couple of days of work.
I implemented a red black tree in Java while in in college. I have always wanted to find that code again and cannot.
Now I do not have the time to recreate it from scratch since I have three kids and do not develop in Java.
I now keep everything so that I can relearn much faster. I also find it fascinating to see how I did something 1, 5, 10 years ago. It makes me feel good because I either did it right or I am better now and would do it differently
If I ever go back to college to give a lecture to future students it in on the list of things to do:
Save everything...
I'm a code packrat, for better or worse, but I guard it, because sometimes it's client-confidential.
On occasion, this has been really useful, like if a client lost their stuff, or their documentation.
I lost a lot of old code (from 10 years ago) because of computer failure that wasn't backed up but in fact I do not really care because I do not really want to see code that is programmed in very old language. Most of this code was written in VB5...
I agree that now it's easy to keep everything but I think sometime it's good to clean up our backup/computer storage because it's like in the real world, we do not need to keep everything forever.
Forever is the beauty of the electronic medium. That's one of the most attractive aspects for me.
But, the keeping of it depends on your coding style, and what you do with it.
I'd suggest tossing your code if you're the type that...
Never looks back.
Would rather re-write from your memory to improve your craft.
Isn't very organized.
Is bothered by latent storage to no end.
Likes to live on the edge.
Worships efficiency of memory.
Logical reasons for tossing could would be...
It bothers you.
It disrupts your workflow by getting in your way.
You're ashamed of it.
It confuses you and distracts you.
Like anything that takes up physical space in life, it's value is weighed against it's usefulness.
All my code is kept indefinitely, with plans to return to it at some point, reflect, and refactor. I do that because it's fun to see my progress, and provides very accessible learning experiences. Furthermore, the incorporation of all my code into a consolidated framework is something I work towards all the time.
Forever...
Good code never dies. ;)
I don't own most of the code I develop: my employer does. So I don't keep that code (my employer does - or should).
Since I discovered computing, I wrote code for devices that no longer exist in languages that are no longer worth. Maybe there is some emulator but keeping that code and running it would be nostalgia.
You can find B-tree information (and many other subjects) on Wikipedia (and many other places). There is no need to keep that code.
In the end I keep only code that I own and maintain.