I'm trying to increase my speed of typing code in a Unity project, and finding a big hole in MonoDevelop.
If I have a method like:
void Foo(float x, float y, float, z) {
//
}
When I start typing
Fo
I want it to autofill with:
Foo(x,y,z)
with the x, y, and z, highlighted green.
Currently, it only autofills with
Foo
I would like functionality like what happens when you type for and hit tab twice, where it autofills:
for(int i = 0; i < max; i++) {
}
with max highlighted in green.
I feel like there should be a built in way to do this, but I can't find anything here or on the web. I know for Java in eclipse it has similar functionality to what I want here.
EDIT: Based on a more refined search from the answer below, I was able to confirm that it doesn't seem like you can do this in MonoDevelop. However, this search revealed that Microsoft just released Visual Studio for Mac, which runs super nicely with Unity and has much better code completion features compared to monodevelop. It still doesn't fill in the parameters, but it at least gives you a little popup window guiding you through which ones you need and what type they are. A huge improvement to say the least. After playing around with it for literally 5 minutes, I'm already prepared to scrap MonoDevelop entirely. The nice thing is the interface is basically identical, just seems like a much more polished and modern version.
for+tab+tab is a Code Snippet that has a whole syntax devoted to typing short things and getting long ones. The for syntax is generally unchanged throughout and so it's easy to write a snippet to cover the general use-case.
Methods are not typically in this category of autocompletion, as the number, type, and name of the paramters will change depending on what method is being completed, and so behavior varies by IDE. Eclipse does the best job I've ever seen, even going so far as to make an educated guess as to which variables available in the current scope would be appropriate as parameters! Its not always right (eg. I've gotten something like Translate(xpos, xpos, xpos) before, when Translate(_x, _y, _z) would have been better).
How, and if, you can get Monodevelop to autocomplete method parameters will likely revolve around these snippets. I don't use MD myself so you'll have to dig into the documentation on making your own snippets, but I suspect it won't be possible (based on my own experience reading the snippets docs for Visual Studio).
Related
For example, sqrt(x). Based on my searches (perhaps most helpfully here), I know that I can import Darwin or UIKit, etc, and get sqrt to work. (Or as per here, .squareRoot()) But for the future, with who knows what function I want to use, how do I find that out on my own without somebody having already asked that here?
In C++ (what I'm more used to), all I have to do is go to any sort of C++ documentation site, search sqrt or square root, and I find out I should include cmath or math.h, and if I want to see what else is in cmath, that's super easy, I just click on it.
But I am having an absolutely terrible time trying to do similar with Swift. If I search either built-in or online documentation, the best searching for sqrt gets me is this, but this has absolutely no indication that I could use this by importing Darwin, not to mention a total lack of description. (Searching square root does find the .squareRoot() luckily, but that's not needing import, so isn't really the question)
Even if I already know (or guess) and import it, then option-click sqrt after I type it, it lets me know it exists and is part of Darwin.C.math, but I can't even click on that to see what else there is in that.
How do you learn this stuff?
Even if I already know (or guess) and import it, then option-click sqrt after I type it, it lets me know it exists and is part of Darwin.C.math, but I can't even click on that to see what else there is in that.
Hope I'm not misunderstanding the issue here, but in your IDE, have you tried cmd-clicking – rather than option-clicking, as you've noted – the function that you want to look up? This will take you directly to Darwin.C.math rather than just telling you that sqrt() lives inside there.
Well, Xcode 8 is out and unfortunately refactoring is still not available for Swift ( Apple (ಠ_ಠ) ).
I'm trying to list all the available options for me to perform complex refactoring (renaming classes, properties used outside of the classes, methods, properties that have name collision with other properties etc..)
What I've come up until now is as follows:
Manually - not an option for me (big and nested project, could result in shorter life span)
Search and replace - better option, but still involves some heavy manual labor (going through each search result and applying replace, because selecting replace all is very risky on just raw text search)
Using AppCode refactoring option - this option seem to be the most promising, but it's seems buggy (not replacing some of the occurrences), also the program doesn't support Xcode 8, and it costs money (I'm on the 30 trial).
all in all, this is the best fail safe solution I can think of.
I was wondering if maybe someone else has other good ways to accomplish complex refactoring on Swift, maybe something that feel safe and robust?
Thanks!
I am using Eclipse (version: Kepler Service Release 1) with Prolog Development Tool (PDT) plug-in for Prolog development in Eclipse. Used these installation instructions: http://sewiki.iai.uni-bonn.de/research/pdt/docs/v0.x/download.
I am working with Multi-Agent IndiGolog (MIndiGolog) 0 (the preliminary prolog version of MIndiGolog). Downloaded from here: http://www.rfk.id.au/ramblings/research/thesis/. I want to use MIndiGolog because it represents time and duration of actions very nicely (I want to do temporal planning), and it supports planning for multiple agents (including concurrency).
MIndiGolog is a high-level programming language based on situation calculus. Everything in the language is exactly according to situation calculus. This however does not fit with the project I'm working on.
This other high-level programming language, Incremental Deterministic (Con)Golog (IndiGolog) (Download from here: http://sourceforge.net/p/indigolog/code/ci/master/tree/) (also made with Prolog), is also (loosly) based on situation calculus, but uses fluents in a very different way. It makes use of causes_val-predicates to denote which action changes which fluent in what way, and it does not include the situation in the fluent!
However, this is what the rest of the team actually wants. I need to rewrite MIndiGolog so that it is still an offline planner, with the nice representation of time and duration of actions, but with the causes_val predicate of IndiGolog to change the values of the fluents.
I find this extremely hard to do, as my knowledge in Prolog and of situation calculus only covers the basics, but they see me as the expert. I feel like I'm in over my head and could use all the help and/or advice I can get.
I already removed the situations from my fluents, made a planning domain with causes_val predicates, and tried to add IndiGolog code into MIndiGolog. But with no luck. Running the planner just returns "false." And I can make little sense of the trace, even when I use the GUI-tracer version of the SWI-Prolog debugger or when I try to place spy points as strategically as possible.
Thanks in advance,
Best, PJ
If you are still interested (sounds like you might not be): this isn't actually very hard.
If you look at Reiter's book, you will find that causes_vals are just effect axioms, while the fluents that mention the situation are usually successor-state-axioms. There is a deterministic way to convert from the former to the latter, and the correct interpretation of the causes_vals is done in the implementation of regression. This is always the same, and you can just copy that part of Prolog code from indiGolog to your flavor.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
For example, what piece of code is considered better styled? If I show my code to a professional developer and ask if my code is good or not, will using the second style be probably considered as a (minor, but...) minus or a plus to my code quality?
I myself tend to like the second style but would prefer to comply to the most common opinion in this case.
1
val foo : Int = -1
val bar : Int = 1
val yohoho : Double = NaN
2
val foo : Int = -1
val bar : Int = 1
val yohoho : Double = NaN
Did you change your tags? I see several answers referring to Python but the only language tag I see is Scala. If you're interested in Scala I would refer to the unofficial Scala Style Guide. Based on the style guide I would suggest your example should look like this:
val foo = -1
val bar = 1
val yohoho = Double.NaN
The second style will get messed up when variables are renamed using refactoring tools.
It's just my humble opinion, but I personally just hate indentation like the second variant in any programming language. Some claim that "it looks nice" but I find it completely impractical. For example in order to rename the variable yohoho you have to realign all the other variables around (and most editors won't help you with that).
Whatever suits you, you're the coder. The first one just looks funny to me really.
Python's PEP 8 (which is the "Style Guide for Python Code") requests that you don't use whitespace to align code:
Pet Peeves
Avoid extraneous whitespace in the following situations:
....
- More than one space around an assignment (or other) operator to
align it with another.
Yes:
x = 1
y = 2
long_variable = 3
No:
x = 1
y = 2
long_variable = 3
I've tried this with Python, for instance in Django model declarations.
It becomes an OCD inducing pain when you're modifying the code later on. For instance, what if you add a var called yoohoohoey in the 2nd example? You have to go back and add spaces to each line to align it to the new length.
So, I prefer to do things the first way.
Scala doesn't force you to work in either style, but the first is generally preferred because it can really play havoc with diff tools if you have to add a new line and then respace everything else...
On the other hand, if your code/algorithm is much more readable when it's aligned, then align it! Readability trumps all other concerns, as per the agile manifesto:
Individuals and interactions over processes and tools
i.e. It's more important to keep other programmers happy than to keep diff tools happy.
I use the second way, if necessary. Is time consuming to do, but with a bit of time you can configure the auto formatting to make it automatically.
But this is a matter of preference.
The Scala Style Guide is silent on the subject, but I haven't seen vertically align declarations in Scala code, so I'd go with the first choice.
If your goal is to conform to community guidelines, probably the first is more common. But are you looking to fit in -- or to stand out by the quality of your code? Learning what works for you is extremely important.
I suggest you try both styles -- then see how you find working with both. For me, aligning variables is a pain, but it's very helpful when working with larger code files. It's also a nice bit of busy work when I'm stuck on some particular aspect of code and want a little time to let my ideas percolate.
Along this same line of thought, I find that when working with, say, JavaScript, pushing the first line of a function to the far left allows me to scan code very rapidly. That breaks normal indentation rules -- but it's helped me read code far better than nicely indented code.
Whatever suits you is only good enough if you work on your own. If you're part of a group of developers, you should vote and stick to one way. Keep a list of coding standards and enforce it in code reviews.
How often do you have multiple initialized val or var declarations in a Scala file anyway? Top level vals and vars in classes should mostly be primary constructor parameters, if possible. Top level vals in traits will likely be abstract, and thus not initialized. Vals and vars inside methods should absolutely not be padded, as reordering is entirely too likely.
I just searched through a 200 class Scala project, and only found one class where this issue even arises (a "cake pattern" module, where the vals declare the components of my application). It's a non-issue.
Whatever suits you, you're the coder. The second one just looks funny to me really.
Whatever suits you, you're the coder. I find the second one is more of a pain to edit.
I can't speak for Python, but in general you will find both examples across all different languages. In my experience, the first example is more common, but it's a matter of personal taste and I don't believe that another developer would think poorly of you for using either style.
I greatly prefer the first example and agree with others who have commented on the maintainability of the second example. With syntax highlighting available in all IDEs and most quality text editors these days, I don't think the latter style is necessary to keep things readable.
From a usability standpoint while reading, the second is akin to a table layout and it helps you scan it vertically to quickly see that there're two Ints and one Double, but it's also slightly harder to connect the horizontal extremes to see that bar is 1.
The first one makes the individual rows take focus and is easier to scan horizontally to see that bar is 1 but it's harder to quickly see that there're two Ints and one Double.
Expand the example with a lot more lines and it might be easier to "feel" this - but which one to use would be up to which is more important and of course what style is used in the project, team, workplace or best practice for the language in question.
Also, why limit table layouts to only left-aligned columns? ^^
val foo : Int = -1
val bar : Int = 1
val yohoho : Double = NaN
Second style giving headache when you need to search for specific text. When code file grows large sometime you need to seek for specific text, If you coding with custom spaces it is hard to find.
We had bad experience with large XML files holding TSQL scripts, Coders before me using style 2 as in your example, end whenever We added new rule or upgrade old one it is painful to search trough files which is codded with custom spaces.
This kind of indentation is useful when someone reads the code, but it is quite up to you to decide.
My answer is don't use it, you will save some time, and you really want to use it, make some text editor that does it, or maybe do yourself some compiler that interpret printed html code, because it's worthless to do it on a text file, which I'll remind you, is a plain long line of bytes reorganized with tabs, space and return carriages.
How would you define "unwanted code"?
Edit:
IMHO, Any code member with 0 active calling members (checked recursively) is unwanted code. (functions, methods, properties, variables are members)
Here's my definition of unwanted code:
A code that does not execute is a dead weight. (Unless it's a [malicious] payload for your actual code, but that's another story :-))
A code that repeats multiple times is increasing the cost of the product.
A code that cannot be regression tested is increasing the cost of the product as well.
You can either remove such code or refactor it, but you don't want to keep it as it is around.
0 active calls and no possibility of use in near future. And I prefer to never comment out anything in case I need for it later since I use SVN (source control).
Like you said in the other thread, code that is not used anywhere at all is pretty much unwanted. As for how to find it I'd suggest FindBugs or CheckStyle if you were using Java, for example, since these tools check to see if a function is used anywhere and marks it as non-used if it isn't. Very nice for getting rid of unnecessary weight.
Well after shortly thinking about it I came up with these three points:
it can be code that should be refactored
it can be code that is not called any more (leftovers from earlier versions)
it can be code that does not apply to your style-guide and way-of-coding
I bet there is a lot more but, that's how I'd define unwanted code.
In java i'd mark the method or class with #Deprecated.
Any PRIVATE code member with no active calling members (checked recursively). Otherwise you do not know if your code is not used out of your scope analysis.
Some things are already posted but here's another:
Functions that almost do the same thing. (only a small variable change and therefore the whole functions is copy pasted and that variable is changed)
Usually I tell my compiler to be as annoyingly noisy as possible, that picks 60% of stuff that I need to examine. Unused functions that are months old (after checking with the VCS) usually get ousted, unless their author tells me when they'll actually be used. Stuff missing prototypes is also instantly suspect.
I think trying to implement automated house cleaning is like trying to make a USB device that guarantees that you 'safely' play Russian Roulette.
The hardest part to check are components added to the build system, few people notice those and unused kludges are left to gather moss.
Beyond that, I typically WANT the code, I just want its author to refactor it a bit and make their style the same as the rest of the project.
Another helpful tool is doxygen, which does help you (visually) see relations in the source tree.. however, if its set at not extracting static symbols / objects, its not going to be very thorough.