The Big Programming Thread - Page 665
Forum Index > General Forum |
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. | ||
3FFA
United States3931 Posts
| ||
Deleted User 3420
24492 Posts
edit: let me rephrase this my program takes input with scanner. I ask a question and I want the user to type an answer but, the blinking cursor that shows that they can type something in does not move to the end of the question where they will type it in. it blinks at the start of the question. I want it to blink where they will type it in. example "_" <----this underscore is the blinking cursor that suggests you can input in my program i say: System.out.print("type a number:"); numbervariable = scannername.nextint; And on my screen this looks like: type a number: but I want it to look like: type a number: _ | ||
spinesheath
Germany8679 Posts
Afaik the cursor for text input is usually called a caret. | ||
Deleted User 3420
24492 Posts
If I compiled the program would it behave differently? It looks like there are methods that let you manipulate the "caret" | ||
RoomOfMush
1296 Posts
You dont have to care about this though because in a regular terminal this will be different. | ||
Manit0u
Poland17187 Posts
On September 18 2015 14:49 Blisse wrote: https://gist.github.com/Blisse/e68b99719c8e035a31f1 could use comments and a couple places could be done better but it's supposed to be rough ![]() Why so many loops in there? All you really have to do is: + Show Spoiler + 1. Split your text into words.
2. Write a simple method to which you'll pass your words and a number, so you can do this:
Of course, this needs some fleshing out, like running #2 recursively, incrementing the counter and building up your final string from formatted lines. Another thing would be not necessarily always adding a space after a word (if it's the last word in a line). Spoilered it, as requested. I hope you'll be able to find some useful methods that are already present in Java in the code I posted ![]() | ||
Chocolate
United States2350 Posts
On September 21 2015 02:30 travis wrote: It is eclipse If I compiled the program would it behave differently? It looks like there are methods that let you manipulate the "caret" My friends run into this all the time when they take the intro CS class at my school If you don't figure out an easy way to fix it, I would just give intellij IDEA a shot. In my opinion eclipse is just too sluggish anyway | ||
Acrofales
Spain17836 Posts
| ||
Chocolate
United States2350 Posts
Regardless, it would at least get around the silly IDE console error | ||
Manit0u
Poland17187 Posts
| ||
phar
United States1080 Posts
| ||
TMG26
Portugal2017 Posts
Whenever I try some new tech, i always check if there are some jetbrains product that supports it. | ||
Acrofales
Spain17836 Posts
On September 23 2015 22:41 TMG26 wrote: Jetbrains productd uses the disk a lot. Having an SSD is recommended. Whenever I try some new tech, i always check if there are some jetbrains product that supports it. Only used pycharm so far and it's great. If all their products are as good then definitely go with them. | ||
Cyx.
Canada806 Posts
On September 22 2015 05:39 Acrofales wrote:Eclipse is supersonic in comparison. You seem to have had a *very* different experience with Eclipse than I did. e: now that I think about it, I've never tried IntelliJ so maybe the comparison is apt... but this is one of the reasons I hate IDEs :D emacs ftw (and when an emacs user is calling your IDE slow it might be time to reconsider your path in life ![]() | ||
Cynry
810 Posts
Sorry in advance, but I need to RANT ! A little bit of context: Beginning of summer I started working as programmer on a web project carried by professionnals (I'm officially a student still). Stuff happenned, I ended up as the only one working on it, but at this point no code is written. I decide (big mistake, I see that now) to bring 2 friends to the party, and all 3 of us start working, with me acting as a sort of team leader. For which I'm not trained or particularly skilled, but whatever. We pick meteor, start working on some basic templates to get an idea of how big the project is. And it's big. And there's plan to extend it even way more after release, but being short on time (we have 1 month before a first release at this point) we just move forward and try to have something to show without thinking much about long term. 2 weeks ago, we meet someone working on a very similar project, except he has been for years now, and is of course quite knowledgeable and willing to share with us. Right after this meeting, we learn that we have 1 more month then we thought. So in light of all these new informations, I ask the team if they're ok with considering building something good right from the start, now that we have the time. They're ok with that, I come up with a nice solution the next day,on which we agree to work. So I start this very task, and spend my week-end cleaning up what we've done and bringing it to the new standards. In no particular order, what I did: unified all collections (yay mongo) with schema.org as a basis, added a type field which allow a unified code for all database interactions (instead of Users.find and Teams. find we now have Collections.find which will point to the right collection according to the type queried.). Factorised templates, declared a new namespace supposed to contain all logic cut in small reusable functions, and a caller for that logic that does all the "get documents, apply logic to them, update them" cleanly. So we end up with what I would consider to be good code. Templates and collections have very little logic on their own, all they do is call a particular set of logic functions which are all in their own folder. It can handle security, owner rights, checks for if an action is possible or not, and it even message the user of what's going on. It has one issue though. You can't work with it yet. That's my big mistake, after all the moving around of files and functions, the main piece, the logic caller, is not quite tuned. And I miss that, and I'm already trying to add new stuff to the architecture, without communicating much of it with the team. Screwed up on that one, yeah. But still, we spend the week on skype all day every day, aaaand it's pretty quiet. I'm exploring dead ends, one is working with something that I never saw, the other doing not much. Middle of the week, I declare my exploration time as over and tell the team we're now back on track on what we all agreed on. T suggests that we review all the code and comment it, we try that, but again apathy from them leads to not much. That was last friday. I'm off for the week end, without being able to connect to skype. Come home on monday, start working, and when they finally get up (~4pm..), they announce that they have been working on the old architecture (or rather lack of) on their own for 4 days now, without telling me. Reason : "durr we didn't understand what was going on, urr at least now it's easy and clear" WHAT. THE. FUCK. So yeah, there I am, starting my day, looking at this fugly code and not motivated one bit. Since then I managed to convince them back that it was a good idea, but the harm is done and I have to clean all that shit again, while arguing againt logical fallacies for everything that I want to add. Not gonna lie, kinda wish I had some real team leader powers here. Like fire these 2 fucking amateurs... | ||
spinesheath
Germany8679 Posts
1) Code that the whole team understands is of higher priority than clean code. As much as it hurts to read bad code. You have to work with the team you have and you have to accept that nobody is perfect. Help your team improve with a positive attitude. Depending on the personalities in the team this can tough to pull off without pissing anyone off. 2) Don't do huge refactorings. Especially don't do them alone. It's good to have a goal to refactor towards, but you should work out a series of smaller refactorings that lead towards the final architecture. Don't break the software with any of these smaller refactorings. Space those refactorings out over couple weeks or months. This way everyone on the team has enough time to catch up on the new stuff. If you're already done with the huge refactoring then you probably shouldn't go back and do the small refactorings anymore. That would just increase confusion. But you'll have to invest a bunch of time to make sure everyone understands the new code. Make it clear that you're willing to help. This again can be a problem with your team, of course, because many people don't want to admit they don't undestand something. Them working on the old code behind your back is bad, but you should find out why they did that instead of asking you for help with the new code. | ||
Cynry
810 Posts
As a team leader having a fully functional team is indeed the priority, but as a person, it still irritates me ^^ The infuriating thing is that the refactoring was done and agreed upon, and they scratched everything because they couldn't figure what was the point of a small part of it after a week of not asking what was the point of that part. Not sure what you mean by "If you're already done with the huge refactoring then you probably shouldn't go back and do the small refactorings anymore". Shouldn't I try to slowly bring back the better architecture ? | ||
spinesheath
Germany8679 Posts
On September 24 2015 19:56 Cynry wrote: Not sure what you mean by "If you're already done with the huge refactoring then you probably shouldn't go back and do the small refactorings anymore". Shouldn't I try to slowly bring back the better architecture ? Of course you should. I just figured you already had worked on getting their new code refactored for the new architecture. But I really shouldn't give you any recommendations whether you should keep the big refactoring or scratch it and start with the small ones. You'll have to judge by yourself which way will be easier for you and your team. | ||
Manit0u
Poland17187 Posts
I'm asking because I don't know much about pure JS apps myself and one of the most common problems you run into with bigger apps is having to work with large amounts of data which means you need to filter it somehow, use lazy fetching etc. Most common things already have libraries for that (Java Hibernate, PHP Doctrine etc.) but I can't seem to find anything like that for JS. It's easy to make a mistake of rendering a select form field and not realize it has 20k+ options in it, which slows down (if not outright kills) your app tremendeously and is a nightmare from UX perspective. That's where you should have searchers on all except most basic select fields that will fetch only required parts of the data. Something to think about as you develop your app. Edit: Also, please do get/create some faker and fill up your db to the brim with entries and see how everything works then. Testing with 5-10 records isn't really the same as doing it with 5-10k records in each table. | ||
Cynry
810 Posts
I'm no expert on Meteor yet, only been working with it for a couple months now, so there's that too. As I see it, this issue is pretty much solved by using intelligent queries when fetching data from the database, be it client or server. Basically, the client gets a mirror of the server database, filtered by the following: -Meteor.publish on the server, which allows you to set some names (a bit like routes) for access to specified data. Specification of what is returned uses the regular mongodb queries syntax, so you can limit (even dynamically) the fields you want to return, according or not to the user status (connected, admin etc); -Meteor.subscribe on the client, which calls the previously defined published data by its name, and you can specifiy here too which data you want to receive. These 2 combines forms the client side database (minimongo collections), but does not fetch any documents in it. It's just which data and fields of this data you can even see. You then need to fetch it with the usual mongo .find().fetch() or .findOne(), and here again, you can limit the field you're actually returning to your logic. This is also valid on the server side, except it works with the whole database instead of the minimongo mirror. So there's that, built-in Meteor, that could work. There's also a schema package, that works a lot like Doctrine (except it's JSON), called SimpleSchema, which provides an customisable autoform option It can even turn mongo into a SQL-like database by attaching schema directly to collections (thus forcing checks on a user defined allowed set of fields for every insert/update) Edit: I tried to ctrl + s this message way too many times ... | ||
| ||