Search Results

Search found 91526 results on 3662 pages for 'clean code'.

Page 173/3662 | < Previous Page | 169 170 171 172 173 174 175 176 177 178 179 180  | Next Page >

  • problem with converting simple code to silverlight app.

    - by Sara
    Hi. I have this code for window form application and I have been attempting to convert it to a Silverlight application but it does not work!. There is a Textbox and I attached KeyDown event handler to it. when the user press the arrow key ( left or right) while the focus on the textbox, it will write . or -. When it is window form i used e.KeyCode and Keys.Right and its works great but when it is silverlight I used e.Key and key.Right and the program doesn't work good because the arrows do the 2 functions moving and write ./-. How I can work this out in Silverlight? (My English not good) The code ( window form): private void textBox1_KeyDown(object sender, KeyEventArgs e) { if (sender is TextBox) { TextBox textBox = (TextBox)sender; if (e.KeyCode == Keys.Left || e.KeyCode == Keys.Right) { e.Handled = true; char insert; if (e.KeyCode == Keys.Left) { insert = '.'; } else { insert = '-'; } int i = textBox.SelectionStart; textBox.Text = textBox.Text.Insert(i, insert.ToString()); textBox.Select(i + 1, 0); } } } (and Silverlight): private void textBox1_KeyDown(object sender, KeyEventArgs e) { if (sender is TextBox) { TextBox textBox = (TextBox)sender; if (e.Key == Key.Left || e.Key == Key.Right) { e.Handled = true; char insert; if (e.Key == Key.Left) { insert = '.'; } else { insert = '-'; } int i = textBox.SelectionStart; textBox.Text = textBox.Text.Insert(i, insert.ToString()); textBox.Select(i + 1, 0); } } } I don't understand, is there huge different effect between using Keycode/Keys and Key/Key or because something else?

    Read the article

  • Expression Blend doesn't recognize command objects declared in code behind file

    - by Brian Ensink
    I have a WPF UserControl. The code behind file declares some RoutedUICommand objects which are referenced in the XAML. The application builds and runs just fine. However Expression Blend 3 cannot load the XAML in the designer and gives errors like this one: The member "ResetCameraCommand" is not recognized or accessible. The class and the member are both public. Building and rebuilding the project in Blend and restarting Blend hasn't helped. Any ideas what the problem is? Here are fragments of my XAML ... <UserControl x:Class="CAP.Visual.CameraAndLightingControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:CAP.Visual;assembly=VisualApp" Height="100" Width="700"> <UserControl.CommandBindings> <CommandBinding Command="local:CameraAndLightingControl.ResetCameraCommand" Executed="ResetCamera_Executed" CanExecute="ResetCamera_CanExecute"/> </UserControl.CommandBindings> .... ... and the code behind C# namespace CAP.Visual { public partial class CameraAndLightingControl : UserControl { public readonly static RoutedUICommand ResetCameraCommand; static CameraAndLightingControl() { ResetCameraCommand = new RoutedUICommand("Reset Camera", "ResetCamera", typeof(CameraAndLightingControl)); }

    Read the article

  • IDE framework for a dynamic language?

    - by Kevin Reid
    Let's say I have a super-wonderful new programming language, and I want there to be an IDE for it. What IDE platform/framework could I use to get this done efficiently? I mean things like: Collection of files in a project, searching them, tabbed/split editors etc. — the basics. Syntax highlighting and auto-indent/reformatting. Providing the user interface for code completion — hit tab, get a list (I'll have to implement the necessary partial evaluation myself (it's a dynamic language)). This is the feature I'm most wishing for. Built-in parser framework which is good at recovering from the sort of syntax errors occurring in code that is in the middle of being edited would be helpful. In-editor annotation of syntax/runtime error locations fed back from the language runtime. REPL (interactive evaluator) interaction with the same completion as in the editor. This system should be Linux/Mac/Windows cross-platform (in that priority order). Being implemented in Java (or rather, accepting language plugins written in Java) is possibly useful, but anything else is worth a try too.

    Read the article

  • Redirecting to frontpage after 404 error in PHP

    - by Saif Bechan
    I have a php web page that now uses custom error pages when a page is not found. The custom error pages are included in PHP. So when somebody types in an URL that does not exists I just include an error page, and the error page starts with: <?php header("HTTP/1.1 404 Not> Found"); ?> This also tells crawlers that the page does not exist. Now I have set up a new system. When a user types a wrong url, the user is sent back to the frontpage and a message is displayed on the frontpage. I redirect to the frontpage like this: header('Location:' . __TINY_URL . '/'); Now the problem is PHP just sends back a 200 code, page found. How can I mix these two to create a 404 code on the frontpage. And is this overall a nice way of presenting and error page.

    Read the article

  • Why not put all braces inline in C++/C#/Java/javascript etc.?

    - by DanM
    Of all the conventions out there for positioning braces in C++, C#, Java, etc., I don't think I've ever seen anyone try to propose something like this: public void SomeMethod(int someInput, string someOtherInput) { if (someInput > 5) { var addedNumber = someInput + 5; var subtractedNumber = someInput - 5; } else { var addedNumber = someInput + 10; var subtractedNumber = someInput; } } public void SomeOtherMethod(int someInput, string someOtherInput( { ... } But why not? I'm sure it would take some getting used to, but I personally don't have any difficulty following what's going on here. I believe indentation is the dominant factor in being able to see how code is organized into blocks and sub-blocks. Braces are just visual noise to me. They are these ugly things that take up lines where I don't want them. Maybe I just feel that way because I was weened on basic (and later VB), but I just don't like braces taking up lines. If I want a gap between blocks, I can always add an empty line, but I don't like being forced to have gaps simply because the convention says the closing brace needs to be on its own line. I made this a community wiki because I realize this is not a question with a defined answer. I'm just curious what people think. I know that no one does this currently (at least, not that I've seen), and I know that the auto-formatter in my IDE doesn't support it, but are there are any other solid reasons not to format code this way, assuming you are working with a modern IDE that color codes and auto-indents? Are there scenarios where it will become a readability nightmare? Better yet, are you aware of any research on this?

    Read the article

  • Reorganizing development environment for single developer/small shop

    - by Matthew
    I have been developing for my company for approximately three years. We serve up a web portal using Microsoft .NET and MS SQL Server on DotNetNuke. I am going to leave my job full time at the end of April. I am leaving on good terms, and I really care about this company and the state of the web project. Because I haven't worked in a team environment in a long time, I have probably lost touch with what 'real' setups look like. When I leave, I predict the company will either find another developer to take over, or at least have developers work on a contractual basis. Because I have not worked with other developers, I am very concerned with leaving the company (and the developer they hire) with a jumbled mess. I'd like to believe I am a good developer and everything makes sense, but I have no way to tell. My question, is how do I set up the development environment, so the company and the next developer will have little trouble getting started? What would you as a developer like in place before working on a project you've never worked on? Here's some relevant information: There is a development server onsite and a production server offsite in a data center . There is a server where backups and source code (Sourcegear Vault) are stored. There is no formal documentation but there are comments in the code. The company budget is tight so free suggestions will help the best. I will be around after the end of April on a consulting basis so I can ask simple questions but I will not be available full time to train someone

    Read the article

  • Cannot write the output to a text file in cpp program

    - by swapedoc
    I have this input file "https://code.google.com/codejam/contest/351101/dashboard/do/A-large-practice.in?cmd=GetInputFile&problem=374101&input_id=1&filename=A-large-practice.in&redownload_last=1&agent=website&csrfmiddlewaretoken=OWMxNTVmMTUyODBiYjhhN2Q2OTM3ZGJiMTNhNDkwMDF8fDEzNzIxNzI1NTE3ODAzMjA%3D" I tried to read this file :-using freopen("filename.txt",r,stdin); and then I wanted the output written to be written to another text file which I can upload in this codejam practice question for the judge. #include<iostream> #include<cstdio> using namespace std; int main() { int t,k=0,a[2000]; freopen("ab.txt","r",stdin); scanf("%d",&t); while(t--) { freopen("cb.txt","w",stdout); int c; scanf("%d",&c); int n; scanf("%d",&n); for(int i=0;i<n;i++) scanf("%d",&a[i]); printf("Case #%d: ",++k); for(int i=0;i<n-1;i++) {for(int j=i+1;j<n;j++) if((a[i]+a[j])==c) {printf("%d %d\n",i+1,j+1); i=n;} } } return 0; } This is my code. Now the problem is the output file cb.txt contains only the last line of the input. I want the the whole of the output to be written to cb.txt,so what should I do.

    Read the article

  • How should I name a native DLL distributed in both 32-bit and 64-bit form?

    - by Spike0xff
    I have a commercial product that's a DLL (native 32-bit code), and now it's time to build a 64-bit version of it. So when installing on 64-bit Windows, the 32-bit version goes into Windows\SysWOW64, and the 64-bit version goes into... Windows\System32! (I'm biting my tongue here...) Or the DLL(s) can be installed alongside the client application. What should I name the 64-bit DLL? Same name as 32-bit: Two files that do the same thing, have the same name, but are totally non-interchangeable. Isn't that a recipe for confusion and support problems? Different names (e.g. product.dll and product64.dll): Now client applications have to know whether they are running 32-bit or 64-bit in order to reference my DLL, and there are languages where that isn't known until run-time - .NET being just one example. And now all the statically compiled clients have to conditionalize the import declarations: IF target=WIN64 THEN import Blah from "product64.dll" ELSE import Blah from "product.dll" ENDIF The product contains massive amounts of C code, and a large chunk of C++ - porting it to C# is not an option. Advice? Suggestions?

    Read the article

  • EF 4.0 Code only assocation from abstract to derived

    - by Jeroen
    Using EF 4.0 Code only i want to make an assocation between an abstract and normal class. I have class 'Item', 'ContentBase' and 'Test'. 'ContentBase' is abstract and 'Test' derives from it. 'ContentBase' has a property 'Item' that links to an instance of 'Item'. So that 'Test.Item' or any class that derives from 'ContentBase' has an 'Item' navigation property. In my DB every record for Test has a matching record for Item. public class Item { public int Id { get; set;} } public abstract class ContentBase { public int ContentId { get; set;} public int Id { get; set;} public Item Item { get; set;} } public class Test : ContentBase { public string Name { get; set;} } now some init code public void SomeInitFunction() { var itemConfig = new EntityConfiguration<Item>(); itemConfig.HasKey(p => p.Id); itemConfig.Property(p => p.Id).IsIdentity(); this.ContextBuilder.Configurations.Add(itemConfig); var testConfig = new EntityConfiguration<Test>(); testConfig.HasKey(p => p.ContentId); testConfig.Property(p => p.ContentId).IsIdentity(); // the problem testConfig.Relationship(p => p.Item).HasConstraint((p, q) => p.Id == q.Id); this.ContextBuilder.Configurations.Add(testConfig); } This gives an error: A key is registered for the derived type 'Test'. Keys must be registered for the root type 'ContentBase'. anyway i try i get an error. What am i a doing wrong?

    Read the article

  • What exactly does this PHP code do?

    - by Rob
    Alright, my friend gave me this code for requesting headers and comparing them to what the header should be. It works perfectly, but I'm not sure why. Here is the code: $headers = apache_request_headers(); $customheader = "Header: 7ddb6ffab28bb675215a7d6e31cfc759"; foreach ($headers as $header => $value) { // 1 $custom .= "$header: $value"; // 2 } $mystring = $custom; // 3 $findme = $customheader; // 4 $pos = strpos($mystring, $findme); if ($pos !== false) { // Do something } else{ exit(); } //If it doesn't match, exit. I commented with some numbers relating to the following questions: 1: What exactly is happening here? Is it setting the $headers as $header AND $value? 2: Again, don't have any idea what is going on here. 3: Why set the variable to a different variable? This is the only area where the variable is getting used, so is there a reason to set it to something else? 4: Same question as 3. I'm sorry if this is a terrible question, but its been bothering me, and I really want to know WHY it works. Well, I understand why it works, I guess I just want to know more specifically. Thanks for any insight you can provide.

    Read the article

  • Quality of TFS 2008 merged code

    - by paologios
    Does the quality of code merged by TFS 2008 depend on the used programming language? I know merging in Java / Subversion, and merging a branch to its trunk usually does not create much conflicts. Now in my company, we use VB.NET. When I merge two files TFS does not always get code blocks right, e.g. does not find the right If..then / end if lines. To give you an example, I mean: File 2 is created as a branch of File 1. Both files were changed later, now I'm going to merge those files and am recieving conficts: The marked end-if lines (1) are detected as corresponding, meaning the added event handler Button1_Click is being deleted. Now I wonder if this behavior is by language (C# vs. VB.NET) or are other source control solutions just better than TFS? (And I really liked TFS up to now :) ) File 1: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then Label1.Text = "Hello" Label2.Text = "World" End If End Sub Protected Sub Button2_Click(ByVal sender, ByVal e as System.EventArgs) Handles Button2.Click // .... If Page.IsValid Then Label3.Text = "Hello Button 2" End If // .... End Sub File 2 (Branch of File 1): Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then fillTableFromDatabase() End If // (1) End Sub Protected Sub Button1_Click(ByVal sender, ByVal e as System.EventArgs) Handles Button1.Click // do something here End Sub Protected Sub Button2_Click(ByVal sender, ByVal e as System.EventArgs) Handles Button2.Click // .... If Page.IsValid Then End If // (1) // .... End Sub

    Read the article

  • Asp.net Hidden field not having value in code behind, but *is* retaining value after postbacks

    - by KallDrexx
    In my ASCX, I have an asp.net hidden field defined as <asp:HiddenField ID="hdnNewAsset" runat="server" />. In the Code Behind I have the following code: protected void Page_Load(object sender, EventArgs e) { _service = new ArticleDataService(PortalId); if (!IsPostBack) { string rawId = Request[ArticleQueryParams.ArticleId]; DisplayArticleDetails(rawId); } if (hdnNewAsset.Value.Trim() != string.Empty) ProcessNewAsset(); } Now, in my frontend, I have a javascript function to react to an event and set the hidden field and trigger a postback: function assetSelected(assetGuid) { $('input[id*="hdnNewAsset"]').val(assetGuid); __doPostBack() } What's happening is that my hidden field is being set in the markup (chrome shows [ <input type=?"hidden" name=?"dnn$ctr466$Main$ctl00$hdnNewAsset" id=?"dnn_ctr466_Main_ctl00_hdnNewAsset" value=?"98d88e72-088c-40a4-9022-565a53dc33c4">? ] for $('input[id*="hdnNewAsset"]')). However, when the postback occurs, hdnNewAsset.Value is an empty string. What's even more puzzling is that at the beginning of Page_Load Request.Params["dnn$ctr466$Main$ctl00$hdnNewAsset"] shows 98d88e72-088c-40a4-9022-565a53dc33c4, and after the postback my hidden field has the same value (so the hidden field is persisting across postbacks), yet I cannot access this value via hdnNewAsset.Value. Can anyone see what I"m doing wrong?

    Read the article

  • mail send using C# code debugging.

    - by riad
    Dear all, I have to send mail using C#.I follow each and every step properly but i cannot send mail using this below code.Can anybody pls help me to solve this issue??I know its an old issue and i read all the related articles on that's site about it.But cannot solved my issue.So pls help me to solve this code.The error is: Failur sending mail.I use System.Net.Mail to do it using System.Net.Mail; string mailTo = emailTextBox.Text; string messageFrom = "[email protected]"; string mailSubject = subjectTextBox.Text; string messageBody = messageRichTextBox.Text; string smtpAddress = "mail.abc.com"; int smtpPort = 25; string accountName = "[email protected]"; string accountPassword = "123"; MailMessage message = new MailMessage(messageFrom, mailTo); message.Subject = mailSubject; message.SubjectEncoding = System.Text.Encoding.UTF8; message.Body = messageBody; message.BodyEncoding = System.Text.Encoding.UTF8; SmtpClient objSmtp = new SmtpClient(smtpAddress, smtpPort); objSmtp.UseDefaultCredentials = false; NetworkCredential basicAuthenticationInfo = new System.Net.NetworkCredential(accountName, accountPassword); objSmtp.Credentials = basicAuthenticationInfo; objSmtp.Send(message); MessageBox.Show("Mail send properly"); Thanks in advance Riad

    Read the article

  • dropdownlist binding from function in code behind aspx vb

    - by Dr.H
    so I have this working in C# , why it is not working in VB public string[] CustomizedRoles() { int length = Roles.GetAllRoles().Length; string[] arrRoles=Roles.GetAllRoles(); string[] customizedRoles= new string[length+1]; customizedRoles[0] = ""; for (int i = 1; i < length+1; i++) { customizedRoles[i] = arrRoles[i-1]; } return customizedRoles; } asp:GridView.... asp:DropDownList ID="ddlOwnerRolesUpdate" runat="server" DataSource="<%# CustomizedRoles() %" Height="25px" Width="177px" SelectedValue='<%# Bind("Owner") %' where is "Owner" is a data value come from a datasource for the grid it is working fine in C# . in Vb with the same aspx and this code behind it is not working. Public Function CustomizedRoles() As String() Dim length As Integer = Roles.GetAllRoles().Length Dim arrRoles As String() = Roles.GetAllRoles() Dim _customizedRoles As String() = New String(length + 1) {} _customizedRoles(0) = " " For index As Integer = 1 To length _customizedRoles(index) = arrRoles(index - 1) Next Return _customizedRoles End Function can anyone show me how to bind array of string to a dropdownlist from aspx to code behind in VB

    Read the article

  • how to monitor the program code execution? (file creation and modification by code lines etc)

    - by infant programmer
    My program is about triggering XSL transformation, Its fact that this code for carrying out the transformation, creates some dll and tmp files and deletes them pretty soon after the transformation is completed. It is almost untraceable for me to monitor the creation and deletion of files manually, so I want to include some chunk of codelines to display "which codeline has created/modified which tmp and dll files" in console window. This is the relevant part of the code: string strXmlQueryTransformPath = @"input.xsl"; string strXmlOutput = string.Empty; StringReader srXmlInput = null; StringWriter swXmlOutput = null; XslCompiledTransform xslTransform = null; XPathDocument xpathXmlOrig = null; XsltSettings xslSettings = null; MemoryStream objMemoryStream = null; objMemoryStream = new MemoryStream(); xslTransform = new XslCompiledTransform(false); xpathXmlOrig = new XPathDocument("input.xml"); xslSettings = new XsltSettings(); xslSettings.EnableScript = true; xslTransform.Load(strXmlQueryTransformPath, xslSettings, new XmlUrlResolver()); xslTransform.Transform(xpathXmlOrig, null, objMemoryStream); objMemoryStream.Position = 0; StreamReader objStreamReader = new StreamReader(objMemoryStream); strXmlOutput = objStreamReader.ReadToEnd(); // make use of Data in string "strXmlOutput" google and msdn search couldn't help me much..

    Read the article

  • Help improve this Javascript code?

    - by Galilyou
    Hello SO, In short, I'm dealing with Telerik's RadTreeView, and I want enable checking all the child nodes if the user checked the parent node. Simple enough! OK here's my code that handles OnClientNodeChecked event of the TreeView: function UpdateAllChildren(nodes, checked) { var i; for (i = 0; i < nodes.get_count(); i++) { var currentNode = nodes.getNode(i); currentNode.set_checked(checked); alert("now processing: " + currentNode.get_text()); if (currentNode.get_nodes().get_count() > 0) { UpdateAllChildren(currentNode.get_nodes(), checked); } } } function ClientNodeChecked(sender, eventArgs) { var node = eventArgs.get_node(); UpdateAllChildren(node.get_nodes(), node.get_checked()); } And here's the TreeView's markup: <telerik:RadTreeView ID="RadTreeView1" runat="server" CheckBoxes="True" OnClientNodeChecked="ClientNodeChecked"></telerik:RadTreeView> The tree contains quite a lot of nodes, and this is causing my targeted browser (ehm, that's IE7) to really slow down while running it. Furthermore IE7 displays an error message asking me to stop the page from running scripts as it's might make my computer not responsive (yeah, scary enough). So what do you guys propose to optimize this code? Thanks in advance

    Read the article

  • Help me reduce code repetition in a simple jQuery function

    - by user339876
    I have built a carousel using the jQuery cycle plugin. I have 4 links that jump to relevent slides. Right now I have a chunk of code for each link. I am trying to create a single multi-purpose function. $('#features-slide0').click(function() { $('#features-slides').cycle(0); return false; }); $('#features-slide1').click(function() { $('#features-slides').cycle(1); return false; }); $('#features-slide2').click(function() { $('#features-slides').cycle(2); return false; }); $('#features-slide3').click(function() { $('#features-slides').cycle(3); return false; }); I have a rel value on each link that carries the number of the slide. How can I use that to create a single block of code that takes care of the link jump?

    Read the article

  • C# - Bug in Code Logic

    - by Matthew
    I have some code which keeps track of the number of times a button has been clicked. As a matter of fact, when the page first loads, a counter is set to 0. On every postback, the counter is incremented by 1. I have only one button on the page. The main idea behind this is to allow the user to enter some details 4 times. If he enters invalid details for 4 times, he is redirected to an error page. Otherwise, he is redirected to a confirmation page. This is my code: if (!this.IsPostBack) { Session["Count"] = 0; } else { if (Session["Count"] == null) { Session.Abandon(); Response.Redirect("CheckOutErrorPage.htm"); } else { int count = (int)Session["Count"]; if (count == 3) { Session.Abandon(); Response.Redirect("CheckOutFailure.aspx"); } else { count++; Session["Count"] = count; } } } Everything works as it should except that if the user enter invalid details for 3 times and then he enters VALID details on the 4th time, the user is redirected to the Error Page (because he has tried 4 times) instead of the confirmation page. How can I solve this please?

    Read the article

  • Freestanding ARM C++ Code - empty .ctors section

    - by Matthew Iselin
    I'm writing C++ code to run in a freestanding environment (basically an ARM board). It's been going well except I've run into a stumbling block - global static constructors. To my understanding the .ctors section contains a list of addresses to each static constructor, and my code simply needs to iterate this list and make calls to each function as it goes. However, I've found that this section in my binary is in fact completely empty! Google pointed towards using ".init_array" instead of ".ctors" (an EABI thing), but that has not changed anything. Any ideas as to why my static constructors don't exist? Relevant linker script and objdump output follows: .ctors : { . = ALIGN(4096); start_ctors = .; *(.init_array); *(.ctors); end_ctors = .; } .dtors : { . = ALIGN(4096); start_dtors = .; *(.fini_array); *(.dtors); end_dtors = .; } -- 2 .ctors 00001000 8014c000 8014c000 00054000 2**2 CONTENTS, ALLOC, LOAD, DATA <snip> 8014d000 g O .ctors 00000004 start_ctors <snip> 8014d000 g O .ctors 00000004 end_ctors I'm using an arm-elf targeted GCC compiler (4.4.1).

    Read the article

  • converting code from non-(C)ontinuation (P)assing (S)tyle to CPS

    - by Delirium tremens
    before: function sc_startSiteCompare(){ var visitinguri; var validateduri; var downloaduris; var compareuris; var tryinguri; sc_setstatus('started'); visitinguri = sc_getvisitinguri(); validateduri = sc_getvalidateduri(visitinguri); downloaduris = new Array(); downloaduris = sc_generatedownloaduris(validateduri); compareuris = new Array(); compareuris = sc_generatecompareuris(validateduri); tryinguri = 0; sc_finishSiteCompare(downloaduris, compareuris, tryinguri); } function sc_getvisitinguri() { var visitinguri; visitinguri = content.location.href; return visitinguri; } after (I'm trying): function sc_startSiteCompare(){ var visitinguri; sc_setstatus('started'); visitinguri = sc_getvisitinguri(sc_startSiteComparec1); } function sc_startSiteComparec1 (visitinguri) { var validateduri; validateduri = sc_getvalidateduri(visitinguri, sc_startSiteComparec2); } function sc_startSiteComparec2 (visitinguri, c) { var downloaduris; downloaduris = sc_generatedownloaduris(validateduri, sc_startSiteComparec3); } function sc_startSiteComparec3 (validateduri, c) { var compareuris; compareuris = sc_generatecompareuris(downloaduris, validateduri, sc_startSiteComparec4); } function sc_startSiteComparec4 (downloaduris, compareuris, validateduri, c) { var tryinguri; tryinguri = 0; sc_finishSiteCompare(downloaduris, compareuris, tryinguri); } function sc_getvisitinguri(c) { var visitinguri; visitinguri = content.location.href; c(visitinguri); } I'm having to pass lots of arguments to functions now. global in procedural code look like this / self in modular code. Any difference? Will I really have to use OO now? As a last resort, does CPS have an alternative?

    Read the article

  • Should I learn to code?

    - by saltcod
    Hi All, This is more of a philosophical question than a technical one, but I’d like some opinions on it, and I think that there are many others in my position that would benefit. My issue is that I don’t really have time to learn how to code. I know, I know… no one has time anymore, but please hear me out. Since learning to use Drupal about 2 years ago I’ve been involved with several projects wherein I’ve become the default quasi-developer, front-end designer, site manager, and system administrator. What I’ve found is that I can produce fairly nice, feature rich Drupal sites with the wealth of contrib. modules out there (Views, CCK, image handling, etc….). BUT! I can’t code. I know enough PHP to insert something into a block, or re-word a string, but that’s about it. I still don’t really even know how arrays work. My question Succinctly, my question is: Given the time that I have available for all of this stuff – in addition to a full-time job and regular life – am I better off trying to become more expert at the front-end stuff, or should I just learn PHP already? Pros 1. If a project doesn’t use Drupal, I’ll know enough PHP to be able to participate. 2. Learning PHP would help my Drupal development too 3. Learning PHP would make front-end theming easier 4. Learning PHP should give me that missing background in programming – and should allow me to learn other languages in the future Cons 1. At 28, I know I’m not too old to learn anything. But am I too old to become ‘good’? 2. Am I better off getting better and better at front-end UX work? 3. Am I better off farming out the PHP work? Suggestions from coders welcome! Thanks Terry

    Read the article

  • C to Assembly code - what does it mean

    - by Smith
    I'm trying to figure out exactly what is going on with the following assembly code. Can someone go down line by line and explain what is happening? I input what I think is happening (see comments) but need clarification. .file "testcalc.c" .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "x=%d, y=%d, z=%d, result=%d\n" .text .globl main .type main, @function main: leal 4(%esp), %ecx // establish stack frame andl $-16, %esp // decrement %esp by 16, align stack pushl -4(%ecx) // push original stack pointer pushl %ebp // save base pointer movl %esp, %ebp // establish stack frame pushl %ecx // save to ecx subl $36, %esp // alloc 36 bytes for local vars movl $11, 8(%esp) // store 11 in z movl $6, 4(%esp) // store 6 in y movl $2, (%esp) // store 2 in x call calc // function call to calc movl %eax, 20(%esp) // %esp + 20 into %eax movl $11, 16(%esp) // WHAT movl $6, 12(%esp) // WHAT movl $2, 8(%esp) // WHAT movl $.LC0, 4(%esp) // WHAT?!?! movl $1, (%esp) // move result into address of %esp call __printf_chk // call printf function addl $36, %esp // WHAT? popl %ecx popl %ebp leal -4(%ecx), %esp ret .size main, .-main .ident "GCC: (Ubuntu 4.3.3-5ubuntu4) 4.3.3" .section .note.GNU-stack,"",@progbits Original code: #include <stdio.h> int calc(int x, int y, int z); int main() { int x = 2; int y = 6; int z = 11; int result; result = calc(x,y,z); printf("x=%d, y=%d, z=%d, result=%d\n",x,y,z,result); }

    Read the article

  • Logging in "Java Library Code" libs for Android applications

    - by K. Claszen
    I follow the advice to implement Android device (not application!) independent library code for my Android Apps in a seperate "Java Library Code" project. This makes testing easier for me as I can use the standard maven project layout, Spring test support and Continuous Build systems the way I am used to. I do not want to mix this inside my Android App project although this might be possible. I now wonder how to implement logging in this library. As this library will be used on the Android device I would like to go with android.util.Log. I added the followind dependency to my project to get the missing Android packages/classes and dependencies: <dependency> <groupId>com.google.android</groupId> <artifactId>android</artifactId> <version>2.2.1</version> <scope>provided</scope> </dependency> But this library just contains stub method (similar to the android.jar inside the android-sdk), thus using android.util.Log results in java.lang.RuntimeException: Stub! when running my unit tests. How do I implement logging which works on the Android device but does not fail outside (I do not expect it to work, but it must not fail)? Thanks for any advice Klaus For now I am going with the workaround to catch the exception outside android but hope there is a better solution. try { Log.d("me", "hello"); } catch (RuntimeException re) { // ignore failure outside android }

    Read the article

  • Cleaning up PHP Code

    - by Michael
    Hi, I've noticed I am a very sloppy coder and do things out of the ordinary. Can you take a look at my code and give me some tips on how to code more efficiently? What can I do to improve? session_start(); /check if the token is correct/ if ($_SESSION['token'] == $_GET['custom1']){ /*connect to db*/ mysql_connect('localhost','x','x') or die(mysql_error()); mysql_select_db('x'); /*get data*/ $orderid = mysql_real_escape_string($_GET['order_id']); $amount = mysql_real_escape_string($_GET['amount']); $product = mysql_real_escape_string($_GET['product1Name']); $cc = mysql_real_escape_string($_GET['Credit_Card_Number']); $length = strlen($cc); $last = 4; $start = $length - $last; $last4 = substr($cc, $start, $last); $ipaddress = mysql_real_escape_string($_GET['ipAddress']); $accountid = $_SESSION['user_id']; $credits = mysql_real_escape_string($_GET['custom3']); /*insert history into db*/ mysql_query("INSERT into billinghistory (orderid, price, description, credits, last4, orderip, accountid) VALUES ('$orderid', '$amount', '$product', '$credits', '$last4', '$ipaddress', '$accountid')"); /*add the credits to the users account*/ mysql_query("UPDATE accounts SET credits = credits + $credits WHERE user_id = '$accountid'"); /*redirect is successful*/ header("location: index.php?x=1"); }else{ /*something messed up*/ header("location: error.php"); }

    Read the article

  • Constructor initializer list: code from the C++ Primer, chapter 16

    - by Alexandros Gezerlis
    Toward the end of Chapter 16 of the "C++ Primer" I encountered the following code (I've removed a bunch of lines): class Sales_item { public: // default constructor: unbound handle Sales_item(): h() { } private: Handle<Item_base> h; // use-counted handle }; My problem is with the Sales_item(): h() { } line. For the sake of completeness, let me also quote the parts of the Handle class template that I think are relevant to my question (I think I don't need to show the Item_base class): template <class T> class Handle { public: // unbound handle Handle(T *p = 0): ptr(p), use(new size_t(1)) { } private: T* ptr; // shared object size_t *use; // count of how many Handles point to *ptr }; I would have expected something like either: a) Sales_item(): h(0) { } which is a convention the authors have used repeatedly in earlier chapters, or b) Handle<Item_base>() if the intention was to invoke the default constructor of the Handle class. Instead, what the book has is Sales_item(): h() { }. My gut reaction is that this is a typo, since h() looks suspiciously similar to a function declaration. On the other hand, I just tried compiling under g++ and running the example code that uses this class and it seems to be working correctly. Any thoughts?

    Read the article

< Previous Page | 169 170 171 172 173 174 175 176 177 178 179 180  | Next Page >