问题标签 [language-concepts]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c++ - 在常规语法和上下文无关语法中,哪个更强大。也请给我理由
我只是在学习编程语言的原理。我知道常规语法和上下文无关语法的概念及其用法。但是我仍然无法确定哪个更强大以及为什么。请帮忙
提前致谢。
proof - 霍尔逻辑证明
证明以下是正确的。
以下推理规则应该会有所帮助
我一直在网上寻找一个清晰的解释或至少一个示例,但我不太明白,我在下面找到了一些可能有帮助的网站,但没有任何示例。
第 148-160 页
非常感谢任何帮助,我希望看到这个问题完成,以便我可以做其他人,我非常卡住,这本书没有显示任何示例。
这些链接也可能有一些帮助。谢谢,10分!
java - Correct way to construct a Java console program
I'm an old-time programmer from the 80s proficient with C and Pascal. I'm pretty new to Java and its concept. In trying to learn the new ways of Java using OOP techniques I'm rather confused about the right way of putting an application together.
I'm trying to build a basic program with the following rules.
An organisation has its own in-house library. The Staff class is general and has Name and Phone. Some of the employees is a librarian. The others are members. So Member and Librarian are specialised classes. I presume we call them inherited or extended in this context.
Now I'm trying to build basic functionality like input and print a member record. I'm trying to build a text-based menu. Perhaps later I'll consider sub-menus. For now it's just a simple menu.
I don't know if I should make the menu an object as well but that's what I think I'll do.
With this in mind, here's what I've done.
My main program:
StaffClass.java
Menus.java
MemberClass.java
It's the first Java program that I've put together with so many classes in it + a menu system.
My key question is if this is the correct way of assembling a program in Java or is there another way.
Please feel free to suggest the best options/changes to the code. But I'd like to keep the concept of generalisation and specialisation.
Thanks!
javascript - 了解基本变量概念
我很难理解变量的交换。有许多有用的线程解释了如何实际做到这一点,但我很难理解它。我正在谈论的示例是:
在我(非常基本的)理解中,我用简单的英语读到:每个声明的变量c包含变量a指向的任何内容。由于我们在声明之后分配了 a = b,下一个分配不应该使b保持值 2 (因为c指向我们刚刚分配给b的a)吗?
language-concepts - 循环队列理论
我需要帮助理解循环队列的概念。我在 stackoverflow 上阅读了几篇文章,但没有一个答案能回答我遇到的心理障碍。
例如,假设我在循环队列中有 8 个单元格。
假设我插入两个字符 F 和 P,这将使队列更改为。
现在让事情变得有趣,如果我删除 3 个条目会怎样。
显然,我的头部和尾部现在已经改变,并且我有 3 个新的可用位置。但为了更好的措施,我想再添加两个条目。
这是我的问题
我执行对了吗?大声笑当你完全填满队列时会发生什么,因为尾巴和头在同一个位置,即“K”?如果有人可以更详细和清晰地解释这个概念,我将不胜感激。
谢谢!
java - 无法弄清楚代码执行顺序
我有以下代码。
我得到了输出
一切都好。是这样的,应该是这样的。当我在 Z 类中创建 X() 的静态对象时,如下所示
输出没问题,因为静态实例首先加载到 RAM 中。但是当我像这样制作静态对象实例时
我得到以下输出
这真的让我很困惑。据我所知,我应该得到以下输出
首先将实例化 Z 对象,最后实例化 X 对象。在这种情况下,它在第三个实例化。这是为什么?有什么特殊的概念适用于此吗?
java - 如何在方法java之外使用它的构造函数来实例化一个对象
我想用它的构造函数在方法之外实例化一个对象。例子:
如果我现在这样做......我得到这个错误..
我想做这样的事情,这样我就可以在课堂上的任何地方调用 config,现在我不得不实例化配置对象......必须有办法做到这一点......任何帮助将不胜感激,提前致谢。
编辑:
配置类:
oop - Materials on important "concepts" in programming
I'm looking for materials (book, video lecture, ...) that explain "important concepts" in programming such as interface and implementation, types and values, subtyping and inheritance, polymorphism, referential transparency and side effect, immutability, regression/unit/integrated testing etc. I need the material to teach some of my junior colleagues. They just know the syntax of C and have only little programming experiences with toy problems. But they are experts on our own subject (some kind of mathematical data processing). I think those concepts could give a quick guide for my colleagues to think how to express and organize their ideas with a programming language. I know that there is no single "theme" connecting those concepts. So I hardly expect that there exists a material dealing with much of the concepts. But, on the other hand, I think people want such all-in-one materials. So I think there could be a little chance that such materials exist. Any recommendation?
java - Java,具有不同方法的类对象?
这似乎是一个奇怪的问题,但我正在尝试练习编写可重用的代码,或者至少尝试以正确的方式思考它,如果你明白我的意思吗?我有一个任务,涉及编写一个带有几个不同菜单的文本界面。所以有两种方法:(1)每个菜单的一个类(草率)或(2)一个包含所有菜单信息的类(不是草率)。
现在我正在写这篇文章,感觉这可能是一种不好的做法,但是是否有可能拥有一个包含菜单基本组件(标题、MenuOptions 列表等)的类,但是可以在以下位置添加方法下一次?
或者,如果这是不可能/不可取的,这将是做这样的事情的普遍首选方式,(a)单独菜单的单独类,或(b)一个包含不同菜单所有代码的大类?
ios - 这是一个好的编程习惯吗?如果方法上的条件返回带有回调的布尔值
我正在使用 Objective-C 来解决这个问题,但这并不是特定于语言的。
我的用户类中有以下方法,
在我的视图控制器中
没有必要提及我正在执行什么任务。这不是我的问题。
我的问题是:
这是一个好的编程习惯吗?使用接受块的 BOOL 方法作为 if 语句的条件?
这个方法
[User canPerform]
做了两件事。首先,它检查它是否可以执行此特定任务,如果可以,它确实执行该任务。但是方法名称并不能反映这一点。方法名称是canPeform
. 我可以使用ifCanThenPeformThisTask
,但这听起来很奇怪,感觉不像是 BOOL 方法。命名此方法的最佳方法是什么?