I came across this article discussing why the double-check locking paradigm is broken in java. Is the paradigm valid for .net (in particular, C#), if variables are declared volatile?
I'm looking for a script/tool that can be customized to check and enforce coding/naming conventions on a C/C++ code.
It should check for example:
Code lines are wrapped at some length.
Private variables have prefix _
Code is indented properly.
All functions are documented.
I have problem that i just cant figure out right now.
I am trying to develop a Windows-8 style app and im stuck implementing this functionality.
I have a MainWindow which contains a ListBox and a Button (lets say addButton).
When i click the button i navigate to a new page, lets say AddCustomerPage with this.Frame.Navigate(typeof (AddCustomerPage));
AddCustomerPage has 1 textBox and 1 button (lets say doneButton. When i click the button i want the string in the textBox to be added to the ListBox on the previous page.
This is my current functionality:
1. MainWindow is created.
Click addButton
AddCustomer page is created. MainWindow is destroyed(problem).
Click doneButton
A MainWindow object is created with a ListBox with 1 item.
Repeat the add process, i always get a MainWindow with a ListBox with 1 item.
Thanks for the help. Here is the code:
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
this.brainPageController = new PageController();
// add items from the List<String> to the listBox
listGoals.ItemsSource = brainPageController.GetListGoals();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
var parameter = e.Parameter as String;
// a simple controller that adds a string to a List<string>
brainPageController.AddGoal(parameter);
}
private void addButton_Click(object sender, RoutedEventArgs e)
{
this.Frame.Navigate(typeof (GoalsInfo));
}
// VARIABLES DECLARATION
private PageController brainPageController;
}
public sealed partial class GoalsInfo : WinGoalsWIP.Common.LayoutAwarePage
{
public GoalsInfo()
{
this.InitializeComponent();
this.brainPageController = new PageController();
}
protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
{
}
protected override void SaveState(Dictionary<String, Object> pageState)
{
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
brainPageController.AddGoal(nameTextBox.Text);
this.Frame.Navigate(typeof(MainPage), nameTextBox.Text);
}
// VARIABLES DECLARATION
PageController brainPageController;
}
Basically, I want to enter text into a text area, and then use them. For example
variable1:variable2@variable3
variable1:variable2@variable3
variable1:variable2@variable3
I know I could use explode to make each line into an array, and then use a foreach loop to use each line separately, but how would I separate the three variables to use?
How does PHP read if statements?
I have the following if statements in this order
if ( $number_of_figures_in_email < 6) {
-- cut: gives false
}
if($number_of_emails > 0) {
-- cut: gives false
}
if ( $number_of_emails == 0) {
-- cut: gives true
}
The code behaves randomly. It sometimes goes to the third if clause and gives me a success, while sometimes to the one of the first two if clauses when the input variables are constant.
This suggests me that I cannot code only with if statements.
I have a jar file with resources (mainly configuration for caches, logging, etc) that I want to distribute.
I'm having a problem with the relative paths for those resources, so I did what I've found in another stackoverflow question, which said that this was a valid way:
ClassInTheSamePackageOfTheResource.class.getResourceAsStream('resource.xml');
Sadly this does not work.
Any ideas? Thanks!
PS: Obviously I cannot use absolute
paths, and I'd like to avoid
environment variables if possible
So after a few hours of workaround the limitation of Reflection being currently disabled on the Google App Engine, I was wondering if someone could help me understand why object reflection can be a threat. Is it because I can inspect the private variables of a class or are there any other deeper reasons?
For a few days now I'm using NetBeans 6.8 for doing PHP work.
But even if a class-file is included and the methods are public and there's phpDoc used, NetBeans everytime shows "No Suggestions" in the window.
E.g. I type
$user->
and press CTRL+Space, I do expect all the methods and variables but there aren't shown any. ideas?
I have a class definition of the form
class X
{
public:
//class functions
private:
A_type *A;
//other class variables
};
and struct A_type is defined as
struct A_type
{
string s1,s2,s3;
};
Inside the constructor, I allocate appropriate memory for A and try A[0].s1="somestring";
It shows segmentation fault.
Is this kind of declaration invalid, or am I missing something
Hi all, need some help with this code if anyone can answer. Any suggestions are most appreciated.
I have a report that I want to save to my hard drive when clicking a button. When saving the report I want the filename to be created using two pieces of information from the report.
Variables:
Report = "Contract"
Save Location = "C:\Folder\"
File Name = [Customer] & " _ " & [Date]
File Type = PDF
Thank you!
I am using PHP/Java bridge to run PHP scripts on the Tomcat server. Can someone point me to an example as to how to call my PHP scripts from a Java file.
<?php
class X{
//variables
//functions
}
?>
Now I want to call the member functions of class X using its object via a Java file. How do I do this?
I have a form in which few details like three text fields and an image is to be uploaded, now as i submit or save the page it should be redirected to the same form storing the previous values in some variables array, I need this array so that according to the count of this array i can display the grid(listing of data) below the form on every submit..
I'm trying to write fully automated unit tests in JavaScript and I'm looking for a way to read some private variables in various JS functions. I thought I recalled a way to inject privileged members into a function/object (and found an overwhelming occurrence of "no such thing as private in JS") and yet I can't find any resources indicating how.
I'm trying to read through the properties of .prototype but if there's a way, someone out here would know where to direct me faster than I'd find on my own.
Thanks
I have been using this "logic" in C++ and VB with success, but am tied up in Java...
Simply put,
public void DataProviderExample(String user, String pwd, String no_of_links,
String link1, String link2, String link3) {
for (int i=1;i<=no_of_links;i++) {
String link = "link"+i;
System.out.println(link);
}
Now, if the variables link1, link2 and link3 have a value of "X", "Y" and "Z" respectively, upon running this program, I get the following output -
link1
link2
link3
What I want is -
X
Y
Z
Any ideas?
I need to find the certain driver variables for unit sales & their impact on sales. My data is such data the error does not follow normal distribution & the unit sales is also not following any particular statistical distribution. Given such condition, it is difficult for me to use simple liner regression or GLM.
Can any of you please suggest me some non parametric regression technique which I can use in R to model the relationship?
Thanks,
Basically, I have a file like this:
Url/Host: www.example.com
Login: user
Password: password
How can I use RegEx to separate the details to place them into variables?
Sorry if this is a terrible question, I can just never grasp RegEx. So another question would be, can you provide the RegEx, but kind of explain what each part of it is for?
This may be a completely dumb question, but I've seen a couple examples declaring the variables AFTER putting them in bind_param:
http://devzone.zend.com/article/686
I've never seen this done before and all my programming knowledge says I should define them before hand. Is this a valid/preferred way?
I noticed that Joomla uses less secure var type for variables in classes
Why is this?
In my own components,plugins,modules should I follow this convention or use a more secure private, public and protected keywords.
Hello how to use switch loop in my android project ? I want to use Android 2.1
I need JRE 1.7, but I want to use Android 2.1
I use loop like this:
switch ((CHAR[Math.abs(intGen.nextInt()%2)])) {
case "+":
result = random2 + random3;
break;
case "-":
result = random2 + random3;
break;
}
LogCat:
Cannot switch on a value of type String for source level below 1.7. Only convertible int values or enum variables are permitted
Input integer array:
a[8] = { a1, a2, a3, a4, b1, b2, b3, b4 }
Output array:
a[8] = { a1, b1, a2, b2, a3, b3, a4, b4 }
Forget all corner cases, make sure your solution works for any int array of size 2n. You can use one or two temp variables for looping or anything, but you shouldn't use any temp arrays/stacks/queues etc to store entire array or part of array.
I'm able to get answer in O(n*log n), but I'm looking for better solution.
Suppose I typedef an integer or integer array or any known type:
typedef int int2
Then I overload operator * for int2 pairs, now if I initialize variables a and b as int. Then will my * between a and b be the overloaded * ?
How do I achieve overloading an int and yet also use * for int the way they are. Should I create a new type?
This is a pretty noobish question – I'm looking at some Cocoa sample code and there's @interface blocks in the .m files as well as the headers. For instance, in the AppDelegate class header, a UIWindow and UI navigation are defined as instance variables, but the @property declarations are actually made in the implementation file. Is there a functional reason for this, is it a stylistic choice, or… ?